Commit d9edf9e2 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[SK_BUFF]: Introduce igmp_hdr() & friends, remove skb->h.igmph

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cc70ab26
...@@ -80,6 +80,27 @@ struct igmpv3_query { ...@@ -80,6 +80,27 @@ struct igmpv3_query {
__be32 srcs[0]; __be32 srcs[0];
}; };
#ifdef __KERNEL__
#include <linux/skbuff.h>
static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
{
return (struct igmphdr *)skb->h.raw;
}
static inline struct igmpv3_report *
igmpv3_report_hdr(const struct sk_buff *skb)
{
return (struct igmpv3_report *)skb->h.raw;
}
static inline struct igmpv3_query *
igmpv3_query_hdr(const struct sk_buff *skb)
{
return (struct igmpv3_query *)skb->h.raw;
}
#endif
#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */ #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */ #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
#define IGMP_DVMRP 0x13 /* DVMRP routing */ #define IGMP_DVMRP 0x13 /* DVMRP routing */
......
...@@ -240,7 +240,6 @@ struct sk_buff { ...@@ -240,7 +240,6 @@ struct sk_buff {
struct tcphdr *th; struct tcphdr *th;
struct udphdr *uh; struct udphdr *uh;
struct icmphdr *icmph; struct icmphdr *icmph;
struct igmphdr *igmph;
struct iphdr *ipiph; struct iphdr *ipiph;
struct ipv6hdr *ipv6h; struct ipv6hdr *ipv6h;
unsigned char *raw; unsigned char *raw;
......
...@@ -333,8 +333,8 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) ...@@ -333,8 +333,8 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
((u8*)&pip[1])[2] = 0; ((u8*)&pip[1])[2] = 0;
((u8*)&pip[1])[3] = 0; ((u8*)&pip[1])[3] = 0;
pig =(struct igmpv3_report *)skb_put(skb, sizeof(*pig)); skb->h.raw = skb_put(skb, sizeof(*pig));
skb->h.igmph = (struct igmphdr *)pig; pig = igmpv3_report_hdr(skb);
pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT; pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT;
pig->resv1 = 0; pig->resv1 = 0;
pig->csum = 0; pig->csum = 0;
...@@ -346,13 +346,13 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) ...@@ -346,13 +346,13 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
static int igmpv3_sendpack(struct sk_buff *skb) static int igmpv3_sendpack(struct sk_buff *skb)
{ {
struct iphdr *pip = ip_hdr(skb); struct iphdr *pip = ip_hdr(skb);
struct igmphdr *pig = skb->h.igmph; struct igmphdr *pig = igmp_hdr(skb);
const int iplen = skb->tail - skb->nh.raw; const int iplen = skb->tail - skb->nh.raw;
const int igmplen = skb->tail - skb->h.raw; const int igmplen = skb->tail - skb->h.raw;
pip->tot_len = htons(iplen); pip->tot_len = htons(iplen);
ip_send_check(pip); ip_send_check(pip);
pig->csum = ip_compute_csum(skb->h.igmph, igmplen); pig->csum = ip_compute_csum(igmp_hdr(skb), igmplen);
return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev, return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev,
dst_output); dst_output);
...@@ -379,7 +379,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc, ...@@ -379,7 +379,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
pgr->grec_auxwords = 0; pgr->grec_auxwords = 0;
pgr->grec_nsrcs = 0; pgr->grec_nsrcs = 0;
pgr->grec_mca = pmc->multiaddr; pgr->grec_mca = pmc->multiaddr;
pih = (struct igmpv3_report *)skb->h.igmph; pih = igmpv3_report_hdr(skb);
pih->ngrec = htons(ntohs(pih->ngrec)+1); pih->ngrec = htons(ntohs(pih->ngrec)+1);
*ppgr = pgr; *ppgr = pgr;
return skb; return skb;
...@@ -412,7 +412,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, ...@@ -412,7 +412,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
if (!*psf_list) if (!*psf_list)
goto empty_source; goto empty_source;
pih = skb ? (struct igmpv3_report *)skb->h.igmph : NULL; pih = skb ? igmpv3_report_hdr(skb) : NULL;
/* EX and TO_EX get a fresh packet, if needed */ /* EX and TO_EX get a fresh packet, if needed */
if (truncate) { if (truncate) {
...@@ -829,8 +829,8 @@ static void igmp_heard_report(struct in_device *in_dev, __be32 group) ...@@ -829,8 +829,8 @@ static void igmp_heard_report(struct in_device *in_dev, __be32 group)
static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
int len) int len)
{ {
struct igmphdr *ih = skb->h.igmph; struct igmphdr *ih = igmp_hdr(skb);
struct igmpv3_query *ih3 = (struct igmpv3_query *)ih; struct igmpv3_query *ih3 = igmpv3_query_hdr(skb);
struct ip_mc_list *im; struct ip_mc_list *im;
__be32 group = ih->group; __be32 group = ih->group;
int max_delay; int max_delay;
...@@ -863,12 +863,12 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, ...@@ -863,12 +863,12 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)))
return; return;
ih3 = (struct igmpv3_query *) skb->h.raw; ih3 = igmpv3_query_hdr(skb);
if (ih3->nsrcs) { if (ih3->nsrcs) {
if (!pskb_may_pull(skb, sizeof(struct igmpv3_query) if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)
+ ntohs(ih3->nsrcs)*sizeof(__be32))) + ntohs(ih3->nsrcs)*sizeof(__be32)))
return; return;
ih3 = (struct igmpv3_query *) skb->h.raw; ih3 = igmpv3_query_hdr(skb);
} }
max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE); max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
...@@ -945,7 +945,7 @@ int igmp_rcv(struct sk_buff *skb) ...@@ -945,7 +945,7 @@ int igmp_rcv(struct sk_buff *skb)
goto drop; goto drop;
} }
ih = skb->h.igmph; ih = igmp_hdr(skb);
switch (ih->type) { switch (ih->type) {
case IGMP_HOST_MEMBERSHIP_QUERY: case IGMP_HOST_MEMBERSHIP_QUERY:
igmp_heard_query(in_dev, skb, len); igmp_heard_query(in_dev, skb, len);
......
...@@ -1430,7 +1430,7 @@ int pim_rcv_v1(struct sk_buff * skb) ...@@ -1430,7 +1430,7 @@ int pim_rcv_v1(struct sk_buff * skb)
if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
goto drop; goto drop;
pim = (struct igmphdr*)skb->h.raw; pim = igmp_hdr(skb);
if (!mroute_do_pim || if (!mroute_do_pim ||
skb->len < sizeof(*pim) + sizeof(*encap) || skb->len < sizeof(*pim) + sizeof(*encap) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment