aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/igmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/igmp.c')
-rw-r--r--net/ipv4/igmp.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 8cedb2a2c9df..2506021c2935 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -314,7 +314,9 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
314 314
315 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 315 skb_reserve(skb, LL_RESERVED_SPACE(dev));
316 316
317 skb->nh.iph = pip =(struct iphdr *)skb_put(skb, sizeof(struct iphdr)+4); 317 skb_reset_network_header(skb);
318 pip = ip_hdr(skb);
319 skb_put(skb, sizeof(struct iphdr) + 4);
318 320
319 pip->version = 4; 321 pip->version = 4;
320 pip->ihl = (sizeof(struct iphdr)+4)>>2; 322 pip->ihl = (sizeof(struct iphdr)+4)>>2;
@@ -331,8 +333,9 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
331 ((u8*)&pip[1])[2] = 0; 333 ((u8*)&pip[1])[2] = 0;
332 ((u8*)&pip[1])[3] = 0; 334 ((u8*)&pip[1])[3] = 0;
333 335
334 pig =(struct igmpv3_report *)skb_put(skb, sizeof(*pig)); 336 skb->transport_header = skb->network_header + sizeof(struct iphdr) + 4;
335 skb->h.igmph = (struct igmphdr *)pig; 337 skb_put(skb, sizeof(*pig));
338 pig = igmpv3_report_hdr(skb);
336 pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT; 339 pig->type = IGMPV3_HOST_MEMBERSHIP_REPORT;
337 pig->resv1 = 0; 340 pig->resv1 = 0;
338 pig->csum = 0; 341 pig->csum = 0;
@@ -343,16 +346,14 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
343 346
344static int igmpv3_sendpack(struct sk_buff *skb) 347static int igmpv3_sendpack(struct sk_buff *skb)
345{ 348{
346 struct iphdr *pip = skb->nh.iph; 349 struct iphdr *pip = ip_hdr(skb);
347 struct igmphdr *pig = skb->h.igmph; 350 struct igmphdr *pig = igmp_hdr(skb);
348 int iplen, igmplen; 351 const int iplen = skb->tail - skb->network_header;
352 const int igmplen = skb->tail - skb->transport_header;
349 353
350 iplen = skb->tail - (unsigned char *)skb->nh.iph;
351 pip->tot_len = htons(iplen); 354 pip->tot_len = htons(iplen);
352 ip_send_check(pip); 355 ip_send_check(pip);
353 356 pig->csum = ip_compute_csum(igmp_hdr(skb), igmplen);
354 igmplen = skb->tail - (unsigned char *)skb->h.igmph;
355 pig->csum = ip_compute_csum((void *)skb->h.igmph, igmplen);
356 357
357 return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev, 358 return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev,
358 dst_output); 359 dst_output);
@@ -379,7 +380,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
379 pgr->grec_auxwords = 0; 380 pgr->grec_auxwords = 0;
380 pgr->grec_nsrcs = 0; 381 pgr->grec_nsrcs = 0;
381 pgr->grec_mca = pmc->multiaddr; 382 pgr->grec_mca = pmc->multiaddr;
382 pih = (struct igmpv3_report *)skb->h.igmph; 383 pih = igmpv3_report_hdr(skb);
383 pih->ngrec = htons(ntohs(pih->ngrec)+1); 384 pih->ngrec = htons(ntohs(pih->ngrec)+1);
384 *ppgr = pgr; 385 *ppgr = pgr;
385 return skb; 386 return skb;
@@ -412,7 +413,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
412 if (!*psf_list) 413 if (!*psf_list)
413 goto empty_source; 414 goto empty_source;
414 415
415 pih = skb ? (struct igmpv3_report *)skb->h.igmph : NULL; 416 pih = skb ? igmpv3_report_hdr(skb) : NULL;
416 417
417 /* EX and TO_EX get a fresh packet, if needed */ 418 /* EX and TO_EX get a fresh packet, if needed */
418 if (truncate) { 419 if (truncate) {
@@ -664,7 +665,9 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
664 665
665 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 666 skb_reserve(skb, LL_RESERVED_SPACE(dev));
666 667
667 skb->nh.iph = iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)+4); 668 skb_reset_network_header(skb);
669 iph = ip_hdr(skb);
670 skb_put(skb, sizeof(struct iphdr) + 4);
668 671
669 iph->version = 4; 672 iph->version = 4;
670 iph->ihl = (sizeof(struct iphdr)+4)>>2; 673 iph->ihl = (sizeof(struct iphdr)+4)>>2;
@@ -827,8 +830,8 @@ static void igmp_heard_report(struct in_device *in_dev, __be32 group)
827static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, 830static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
828 int len) 831 int len)
829{ 832{
830 struct igmphdr *ih = skb->h.igmph; 833 struct igmphdr *ih = igmp_hdr(skb);
831 struct igmpv3_query *ih3 = (struct igmpv3_query *)ih; 834 struct igmpv3_query *ih3 = igmpv3_query_hdr(skb);
832 struct ip_mc_list *im; 835 struct ip_mc_list *im;
833 __be32 group = ih->group; 836 __be32 group = ih->group;
834 int max_delay; 837 int max_delay;
@@ -861,12 +864,12 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
861 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) 864 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)))
862 return; 865 return;
863 866
864 ih3 = (struct igmpv3_query *) skb->h.raw; 867 ih3 = igmpv3_query_hdr(skb);
865 if (ih3->nsrcs) { 868 if (ih3->nsrcs) {
866 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query) 869 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)
867 + ntohs(ih3->nsrcs)*sizeof(__be32))) 870 + ntohs(ih3->nsrcs)*sizeof(__be32)))
868 return; 871 return;
869 ih3 = (struct igmpv3_query *) skb->h.raw; 872 ih3 = igmpv3_query_hdr(skb);
870 } 873 }
871 874
872 max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE); 875 max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
@@ -943,7 +946,7 @@ int igmp_rcv(struct sk_buff *skb)
943 goto drop; 946 goto drop;
944 } 947 }
945 948
946 ih = skb->h.igmph; 949 ih = igmp_hdr(skb);
947 switch (ih->type) { 950 switch (ih->type) {
948 case IGMP_HOST_MEMBERSHIP_QUERY: 951 case IGMP_HOST_MEMBERSHIP_QUERY:
949 igmp_heard_query(in_dev, skb, len); 952 igmp_heard_query(in_dev, skb, len);
@@ -2397,7 +2400,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v)
2397 return 0; 2400 return 0;
2398} 2401}
2399 2402
2400static struct seq_operations igmp_mc_seq_ops = { 2403static const struct seq_operations igmp_mc_seq_ops = {
2401 .start = igmp_mc_seq_start, 2404 .start = igmp_mc_seq_start,
2402 .next = igmp_mc_seq_next, 2405 .next = igmp_mc_seq_next,
2403 .stop = igmp_mc_seq_stop, 2406 .stop = igmp_mc_seq_stop,
@@ -2571,7 +2574,7 @@ static int igmp_mcf_seq_show(struct seq_file *seq, void *v)
2571 return 0; 2574 return 0;
2572} 2575}
2573 2576
2574static struct seq_operations igmp_mcf_seq_ops = { 2577static const struct seq_operations igmp_mcf_seq_ops = {
2575 .start = igmp_mcf_seq_start, 2578 .start = igmp_mcf_seq_start,
2576 .next = igmp_mcf_seq_next, 2579 .next = igmp_mcf_seq_next,
2577 .stop = igmp_mcf_seq_stop, 2580 .stop = igmp_mcf_seq_stop,