aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/igmp.h21
-rw-r--r--include/linux/skbuff.h1
-rw-r--r--net/ipv4/igmp.c22
-rw-r--r--net/ipv4/ipmr.c2
4 files changed, 33 insertions, 13 deletions
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index a113fe68d8a1..ca285527b879 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -80,6 +80,27 @@ struct igmpv3_query {
80 __be32 srcs[0]; 80 __be32 srcs[0];
81}; 81};
82 82
83#ifdef __KERNEL__
84#include <linux/skbuff.h>
85
86static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
87{
88 return (struct igmphdr *)skb->h.raw;
89}
90
91static inline struct igmpv3_report *
92 igmpv3_report_hdr(const struct sk_buff *skb)
93{
94 return (struct igmpv3_report *)skb->h.raw;
95}
96
97static inline struct igmpv3_query *
98 igmpv3_query_hdr(const struct sk_buff *skb)
99{
100 return (struct igmpv3_query *)skb->h.raw;
101}
102#endif
103
83#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */ 104#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
84#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */ 105#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
85#define IGMP_DVMRP 0x13 /* DVMRP routing */ 106#define IGMP_DVMRP 0x13 /* DVMRP routing */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 684292efa823..0a4a7ac034fa 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -240,7 +240,6 @@ struct sk_buff {
240 struct tcphdr *th; 240 struct tcphdr *th;
241 struct udphdr *uh; 241 struct udphdr *uh;
242 struct icmphdr *icmph; 242 struct icmphdr *icmph;
243 struct igmphdr *igmph;
244 struct iphdr *ipiph; 243 struct iphdr *ipiph;
245 struct ipv6hdr *ipv6h; 244 struct ipv6hdr *ipv6h;
246 unsigned char *raw; 245 unsigned char *raw;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index f511d03e2439..292516bb1eca 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -333,8 +333,8 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
333 ((u8*)&pip[1])[2] = 0; 333 ((u8*)&pip[1])[2] = 0;
334 ((u8*)&pip[1])[3] = 0; 334 ((u8*)&pip[1])[3] = 0;
335 335
336 pig =(struct igmpv3_report *)skb_put(skb, sizeof(*pig)); 336 skb->h.raw = skb_put(skb, sizeof(*pig));
337 skb->h.igmph = (struct igmphdr *)pig; 337 pig = igmpv3_report_hdr(skb);
338 pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT; 338 pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT;
339 pig->resv1 = 0; 339 pig->resv1 = 0;
340 pig->csum = 0; 340 pig->csum = 0;
@@ -346,13 +346,13 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
346static int igmpv3_sendpack(struct sk_buff *skb) 346static int igmpv3_sendpack(struct sk_buff *skb)
347{ 347{
348 struct iphdr *pip = ip_hdr(skb); 348 struct iphdr *pip = ip_hdr(skb);
349 struct igmphdr *pig = skb->h.igmph; 349 struct igmphdr *pig = igmp_hdr(skb);
350 const int iplen = skb->tail - skb->nh.raw; 350 const int iplen = skb->tail - skb->nh.raw;
351 const int igmplen = skb->tail - skb->h.raw; 351 const int igmplen = skb->tail - skb->h.raw;
352 352
353 pip->tot_len = htons(iplen); 353 pip->tot_len = htons(iplen);
354 ip_send_check(pip); 354 ip_send_check(pip);
355 pig->csum = ip_compute_csum(skb->h.igmph, igmplen); 355 pig->csum = ip_compute_csum(igmp_hdr(skb), igmplen);
356 356
357 return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev, 357 return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev,
358 dst_output); 358 dst_output);
@@ -379,7 +379,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
379 pgr->grec_auxwords = 0; 379 pgr->grec_auxwords = 0;
380 pgr->grec_nsrcs = 0; 380 pgr->grec_nsrcs = 0;
381 pgr->grec_mca = pmc->multiaddr; 381 pgr->grec_mca = pmc->multiaddr;
382 pih = (struct igmpv3_report *)skb->h.igmph; 382 pih = igmpv3_report_hdr(skb);
383 pih->ngrec = htons(ntohs(pih->ngrec)+1); 383 pih->ngrec = htons(ntohs(pih->ngrec)+1);
384 *ppgr = pgr; 384 *ppgr = pgr;
385 return skb; 385 return skb;
@@ -412,7 +412,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
412 if (!*psf_list) 412 if (!*psf_list)
413 goto empty_source; 413 goto empty_source;
414 414
415 pih = skb ? (struct igmpv3_report *)skb->h.igmph : NULL; 415 pih = skb ? igmpv3_report_hdr(skb) : NULL;
416 416
417 /* EX and TO_EX get a fresh packet, if needed */ 417 /* EX and TO_EX get a fresh packet, if needed */
418 if (truncate) { 418 if (truncate) {
@@ -829,8 +829,8 @@ static void igmp_heard_report(struct in_device *in_dev, __be32 group)
829static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, 829static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
830 int len) 830 int len)
831{ 831{
832 struct igmphdr *ih = skb->h.igmph; 832 struct igmphdr *ih = igmp_hdr(skb);
833 struct igmpv3_query *ih3 = (struct igmpv3_query *)ih; 833 struct igmpv3_query *ih3 = igmpv3_query_hdr(skb);
834 struct ip_mc_list *im; 834 struct ip_mc_list *im;
835 __be32 group = ih->group; 835 __be32 group = ih->group;
836 int max_delay; 836 int max_delay;
@@ -863,12 +863,12 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
863 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) 863 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)))
864 return; 864 return;
865 865
866 ih3 = (struct igmpv3_query *) skb->h.raw; 866 ih3 = igmpv3_query_hdr(skb);
867 if (ih3->nsrcs) { 867 if (ih3->nsrcs) {
868 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query) 868 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)
869 + ntohs(ih3->nsrcs)*sizeof(__be32))) 869 + ntohs(ih3->nsrcs)*sizeof(__be32)))
870 return; 870 return;
871 ih3 = (struct igmpv3_query *) skb->h.raw; 871 ih3 = igmpv3_query_hdr(skb);
872 } 872 }
873 873
874 max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE); 874 max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
@@ -945,7 +945,7 @@ int igmp_rcv(struct sk_buff *skb)
945 goto drop; 945 goto drop;
946 } 946 }
947 947
948 ih = skb->h.igmph; 948 ih = igmp_hdr(skb);
949 switch (ih->type) { 949 switch (ih->type) {
950 case IGMP_HOST_MEMBERSHIP_QUERY: 950 case IGMP_HOST_MEMBERSHIP_QUERY:
951 igmp_heard_query(in_dev, skb, len); 951 igmp_heard_query(in_dev, skb, len);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 03869d91f6f0..05bc27002def 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1430,7 +1430,7 @@ int pim_rcv_v1(struct sk_buff * skb)
1430 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) 1430 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
1431 goto drop; 1431 goto drop;
1432 1432
1433 pim = (struct igmphdr*)skb->h.raw; 1433 pim = igmp_hdr(skb);
1434 1434
1435 if (!mroute_do_pim || 1435 if (!mroute_do_pim ||
1436 skb->len < sizeof(*pim) + sizeof(*encap) || 1436 skb->len < sizeof(*pim) + sizeof(*encap) ||