diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:19:08 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:19:08 -0400 |
| commit | 905ec87e93bc9e01b15c60035cd6a50c636cbaef (patch) | |
| tree | 46fd7618d6511611ffc19eb0dd4d7bc6b90a41c2 /net/ipv6 | |
| parent | 1d6ae775d7a948c9575658eb41184fd2e506c0df (diff) | |
| parent | 2f4ba45a75d6383b4a1201169a808ffea416ffa0 (diff) | |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'net/ipv6')
| -rw-r--r-- | net/ipv6/addrconf.c | 3 | ||||
| -rw-r--r-- | net/ipv6/datagram.c | 139 | ||||
| -rw-r--r-- | net/ipv6/exthdrs.c | 119 | ||||
| -rw-r--r-- | net/ipv6/icmp.c | 20 | ||||
| -rw-r--r-- | net/ipv6/ip6_fib.c | 2 | ||||
| -rw-r--r-- | net/ipv6/ip6_flowlabel.c | 16 | ||||
| -rw-r--r-- | net/ipv6/ip6_output.c | 24 | ||||
| -rw-r--r-- | net/ipv6/ip6_tunnel.c | 7 | ||||
| -rw-r--r-- | net/ipv6/ipv6_sockglue.c | 186 | ||||
| -rw-r--r-- | net/ipv6/ndisc.c | 16 | ||||
| -rw-r--r-- | net/ipv6/netfilter/ip6t_REJECT.c | 5 | ||||
| -rw-r--r-- | net/ipv6/netfilter/ip6t_owner.c | 1 | ||||
| -rw-r--r-- | net/ipv6/netfilter/ip6t_rt.c | 14 | ||||
| -rw-r--r-- | net/ipv6/raw.c | 21 | ||||
| -rw-r--r-- | net/ipv6/reassembly.c | 9 | ||||
| -rw-r--r-- | net/ipv6/tcp_ipv6.c | 36 | ||||
| -rw-r--r-- | net/ipv6/udp.c | 25 |
17 files changed, 514 insertions, 129 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 6d6fb74f3b52..2fea3f4402a0 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -123,8 +123,7 @@ DEFINE_RWLOCK(addrconf_lock); | |||
| 123 | 123 | ||
| 124 | static void addrconf_verify(unsigned long); | 124 | static void addrconf_verify(unsigned long); |
| 125 | 125 | ||
| 126 | static struct timer_list addr_chk_timer = | 126 | static DEFINE_TIMER(addr_chk_timer, addrconf_verify, 0, 0); |
| 127 | TIMER_INITIALIZER(addrconf_verify, 0, 0); | ||
| 128 | static DEFINE_SPINLOCK(addrconf_verify_lock); | 127 | static DEFINE_SPINLOCK(addrconf_verify_lock); |
| 129 | 128 | ||
| 130 | static void addrconf_join_anycast(struct inet6_ifaddr *ifp); | 129 | static void addrconf_join_anycast(struct inet6_ifaddr *ifp); |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 01468fab3d3d..cc518405b3e1 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
| @@ -175,10 +175,8 @@ ipv4_connected: | |||
| 175 | if (final_p) | 175 | if (final_p) |
| 176 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 176 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
| 177 | 177 | ||
| 178 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 178 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 179 | dst_release(dst); | ||
| 180 | goto out; | 179 | goto out; |
| 181 | } | ||
| 182 | 180 | ||
| 183 | /* source address lookup done in ip6_dst_lookup */ | 181 | /* source address lookup done in ip6_dst_lookup */ |
| 184 | 182 | ||
| @@ -390,32 +388,101 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
| 390 | put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); | 388 | put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); |
| 391 | } | 389 | } |
| 392 | 390 | ||
| 391 | if (np->rxopt.bits.rxtclass) { | ||
| 392 | int tclass = (ntohl(*(u32 *)skb->nh.ipv6h) >> 20) & 0xff; | ||
| 393 | put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); | ||
| 394 | } | ||
| 395 | |||
| 393 | if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { | 396 | if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { |
| 394 | u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; | 397 | u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; |
| 395 | put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); | 398 | put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); |
| 396 | } | 399 | } |
| 400 | |||
| 401 | /* HbH is allowed only once */ | ||
| 397 | if (np->rxopt.bits.hopopts && opt->hop) { | 402 | if (np->rxopt.bits.hopopts && opt->hop) { |
| 398 | u8 *ptr = skb->nh.raw + opt->hop; | 403 | u8 *ptr = skb->nh.raw + opt->hop; |
| 399 | put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); | 404 | put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); |
| 400 | } | 405 | } |
| 401 | if (np->rxopt.bits.dstopts && opt->dst0) { | 406 | |
| 407 | if (opt->lastopt && | ||
| 408 | (np->rxopt.bits.dstopts || np->rxopt.bits.srcrt)) { | ||
| 409 | /* | ||
| 410 | * Silly enough, but we need to reparse in order to | ||
| 411 | * report extension headers (except for HbH) | ||
| 412 | * in order. | ||
| 413 | * | ||
| 414 | * Also note that IPV6_RECVRTHDRDSTOPTS is NOT | ||
| 415 | * (and WILL NOT be) defined because | ||
| 416 | * IPV6_RECVDSTOPTS is more generic. --yoshfuji | ||
| 417 | */ | ||
| 418 | unsigned int off = sizeof(struct ipv6hdr); | ||
| 419 | u8 nexthdr = skb->nh.ipv6h->nexthdr; | ||
| 420 | |||
| 421 | while (off <= opt->lastopt) { | ||
| 422 | unsigned len; | ||
| 423 | u8 *ptr = skb->nh.raw + off; | ||
| 424 | |||
| 425 | switch(nexthdr) { | ||
| 426 | case IPPROTO_DSTOPTS: | ||
| 427 | nexthdr = ptr[0]; | ||
| 428 | len = (ptr[1] + 1) << 3; | ||
| 429 | if (np->rxopt.bits.dstopts) | ||
| 430 | put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, len, ptr); | ||
| 431 | break; | ||
| 432 | case IPPROTO_ROUTING: | ||
| 433 | nexthdr = ptr[0]; | ||
| 434 | len = (ptr[1] + 1) << 3; | ||
| 435 | if (np->rxopt.bits.srcrt) | ||
| 436 | put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, len, ptr); | ||
| 437 | break; | ||
| 438 | case IPPROTO_AH: | ||
| 439 | nexthdr = ptr[0]; | ||
| 440 | len = (ptr[1] + 1) << 2; | ||
| 441 | break; | ||
| 442 | default: | ||
| 443 | nexthdr = ptr[0]; | ||
| 444 | len = (ptr[1] + 1) << 3; | ||
| 445 | break; | ||
| 446 | } | ||
| 447 | |||
| 448 | off += len; | ||
| 449 | } | ||
| 450 | } | ||
| 451 | |||
| 452 | /* socket options in old style */ | ||
| 453 | if (np->rxopt.bits.rxoinfo) { | ||
| 454 | struct in6_pktinfo src_info; | ||
| 455 | |||
| 456 | src_info.ipi6_ifindex = opt->iif; | ||
| 457 | ipv6_addr_copy(&src_info.ipi6_addr, &skb->nh.ipv6h->daddr); | ||
| 458 | put_cmsg(msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); | ||
| 459 | } | ||
| 460 | if (np->rxopt.bits.rxohlim) { | ||
| 461 | int hlim = skb->nh.ipv6h->hop_limit; | ||
| 462 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); | ||
| 463 | } | ||
| 464 | if (np->rxopt.bits.ohopopts && opt->hop) { | ||
| 465 | u8 *ptr = skb->nh.raw + opt->hop; | ||
| 466 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); | ||
| 467 | } | ||
| 468 | if (np->rxopt.bits.odstopts && opt->dst0) { | ||
| 402 | u8 *ptr = skb->nh.raw + opt->dst0; | 469 | u8 *ptr = skb->nh.raw + opt->dst0; |
| 403 | put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, (ptr[1]+1)<<3, ptr); | 470 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); |
| 404 | } | 471 | } |
| 405 | if (np->rxopt.bits.srcrt && opt->srcrt) { | 472 | if (np->rxopt.bits.osrcrt && opt->srcrt) { |
| 406 | struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(skb->nh.raw + opt->srcrt); | 473 | struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(skb->nh.raw + opt->srcrt); |
| 407 | put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, (rthdr->hdrlen+1) << 3, rthdr); | 474 | put_cmsg(msg, SOL_IPV6, IPV6_2292RTHDR, (rthdr->hdrlen+1) << 3, rthdr); |
| 408 | } | 475 | } |
| 409 | if (np->rxopt.bits.dstopts && opt->dst1) { | 476 | if (np->rxopt.bits.odstopts && opt->dst1) { |
| 410 | u8 *ptr = skb->nh.raw + opt->dst1; | 477 | u8 *ptr = skb->nh.raw + opt->dst1; |
| 411 | put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, (ptr[1]+1)<<3, ptr); | 478 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); |
| 412 | } | 479 | } |
| 413 | return 0; | 480 | return 0; |
| 414 | } | 481 | } |
| 415 | 482 | ||
| 416 | int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | 483 | int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, |
| 417 | struct ipv6_txoptions *opt, | 484 | struct ipv6_txoptions *opt, |
| 418 | int *hlimit) | 485 | int *hlimit, int *tclass) |
| 419 | { | 486 | { |
| 420 | struct in6_pktinfo *src_info; | 487 | struct in6_pktinfo *src_info; |
| 421 | struct cmsghdr *cmsg; | 488 | struct cmsghdr *cmsg; |
| @@ -438,6 +505,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 438 | 505 | ||
| 439 | switch (cmsg->cmsg_type) { | 506 | switch (cmsg->cmsg_type) { |
| 440 | case IPV6_PKTINFO: | 507 | case IPV6_PKTINFO: |
| 508 | case IPV6_2292PKTINFO: | ||
| 441 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { | 509 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { |
| 442 | err = -EINVAL; | 510 | err = -EINVAL; |
| 443 | goto exit_f; | 511 | goto exit_f; |
| @@ -492,6 +560,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 492 | fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg); | 560 | fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg); |
| 493 | break; | 561 | break; |
| 494 | 562 | ||
| 563 | case IPV6_2292HOPOPTS: | ||
| 495 | case IPV6_HOPOPTS: | 564 | case IPV6_HOPOPTS: |
| 496 | if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { | 565 | if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { |
| 497 | err = -EINVAL; | 566 | err = -EINVAL; |
| @@ -512,7 +581,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 512 | opt->hopopt = hdr; | 581 | opt->hopopt = hdr; |
| 513 | break; | 582 | break; |
| 514 | 583 | ||
| 515 | case IPV6_DSTOPTS: | 584 | case IPV6_2292DSTOPTS: |
| 516 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { | 585 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { |
| 517 | err = -EINVAL; | 586 | err = -EINVAL; |
| 518 | goto exit_f; | 587 | goto exit_f; |
| @@ -536,6 +605,33 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 536 | opt->dst1opt = hdr; | 605 | opt->dst1opt = hdr; |
| 537 | break; | 606 | break; |
| 538 | 607 | ||
| 608 | case IPV6_DSTOPTS: | ||
| 609 | case IPV6_RTHDRDSTOPTS: | ||
| 610 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { | ||
| 611 | err = -EINVAL; | ||
| 612 | goto exit_f; | ||
| 613 | } | ||
| 614 | |||
| 615 | hdr = (struct ipv6_opt_hdr *)CMSG_DATA(cmsg); | ||
| 616 | len = ((hdr->hdrlen + 1) << 3); | ||
| 617 | if (cmsg->cmsg_len < CMSG_LEN(len)) { | ||
| 618 | err = -EINVAL; | ||
| 619 | goto exit_f; | ||
| 620 | } | ||
| 621 | if (!capable(CAP_NET_RAW)) { | ||
| 622 | err = -EPERM; | ||
| 623 | goto exit_f; | ||
| 624 | } | ||
| 625 | if (cmsg->cmsg_type == IPV6_DSTOPTS) { | ||
| 626 | opt->opt_flen += len; | ||
| 627 | opt->dst1opt = hdr; | ||
| 628 | } else { | ||
| 629 | opt->opt_nflen += len; | ||
| 630 | opt->dst0opt = hdr; | ||
| 631 | } | ||
| 632 | break; | ||
| 633 | |||
| 634 | case IPV6_2292RTHDR: | ||
| 539 | case IPV6_RTHDR: | 635 | case IPV6_RTHDR: |
| 540 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { | 636 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { |
| 541 | err = -EINVAL; | 637 | err = -EINVAL; |
| @@ -568,7 +664,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 568 | opt->opt_nflen += len; | 664 | opt->opt_nflen += len; |
| 569 | opt->srcrt = rthdr; | 665 | opt->srcrt = rthdr; |
| 570 | 666 | ||
| 571 | if (opt->dst1opt) { | 667 | if (cmsg->cmsg_type == IPV6_2292RTHDR && opt->dst1opt) { |
| 572 | int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); | 668 | int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); |
| 573 | 669 | ||
| 574 | opt->opt_nflen += dsthdrlen; | 670 | opt->opt_nflen += dsthdrlen; |
| @@ -579,6 +675,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 579 | 675 | ||
| 580 | break; | 676 | break; |
| 581 | 677 | ||
| 678 | case IPV6_2292HOPLIMIT: | ||
| 582 | case IPV6_HOPLIMIT: | 679 | case IPV6_HOPLIMIT: |
| 583 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { | 680 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { |
| 584 | err = -EINVAL; | 681 | err = -EINVAL; |
| @@ -588,6 +685,24 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 588 | *hlimit = *(int *)CMSG_DATA(cmsg); | 685 | *hlimit = *(int *)CMSG_DATA(cmsg); |
| 589 | break; | 686 | break; |
| 590 | 687 | ||
| 688 | case IPV6_TCLASS: | ||
| 689 | { | ||
| 690 | int tc; | ||
| 691 | |||
| 692 | err = -EINVAL; | ||
| 693 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { | ||
| 694 | goto exit_f; | ||
| 695 | } | ||
| 696 | |||
| 697 | tc = *(int *)CMSG_DATA(cmsg); | ||
| 698 | if (tc < 0 || tc > 0xff) | ||
| 699 | goto exit_f; | ||
| 700 | |||
| 701 | err = 0; | ||
| 702 | *tclass = tc; | ||
| 703 | |||
| 704 | break; | ||
| 705 | } | ||
| 591 | default: | 706 | default: |
| 592 | LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", | 707 | LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", |
| 593 | cmsg->cmsg_type); | 708 | cmsg->cmsg_type); |
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 5be6da2584ee..922549581abc 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
| @@ -164,6 +164,7 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp, unsigned int *nhoffp) | |||
| 164 | return -1; | 164 | return -1; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | opt->lastopt = skb->h.raw - skb->nh.raw; | ||
| 167 | opt->dst1 = skb->h.raw - skb->nh.raw; | 168 | opt->dst1 = skb->h.raw - skb->nh.raw; |
| 168 | 169 | ||
| 169 | if (ip6_parse_tlv(tlvprocdestopt_lst, skb)) { | 170 | if (ip6_parse_tlv(tlvprocdestopt_lst, skb)) { |
| @@ -243,6 +244,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp) | |||
| 243 | 244 | ||
| 244 | looped_back: | 245 | looped_back: |
| 245 | if (hdr->segments_left == 0) { | 246 | if (hdr->segments_left == 0) { |
| 247 | opt->lastopt = skb->h.raw - skb->nh.raw; | ||
| 246 | opt->srcrt = skb->h.raw - skb->nh.raw; | 248 | opt->srcrt = skb->h.raw - skb->nh.raw; |
| 247 | skb->h.raw += (hdr->hdrlen + 1) << 3; | 249 | skb->h.raw += (hdr->hdrlen + 1) << 3; |
| 248 | opt->dst0 = opt->dst1; | 250 | opt->dst0 = opt->dst1; |
| @@ -404,8 +406,7 @@ ipv6_invert_rthdr(struct sock *sk, struct ipv6_rt_hdr *hdr) | |||
| 404 | 406 | ||
| 405 | memcpy(opt->srcrt, hdr, sizeof(*hdr)); | 407 | memcpy(opt->srcrt, hdr, sizeof(*hdr)); |
| 406 | irthdr = (struct rt0_hdr*)opt->srcrt; | 408 | irthdr = (struct rt0_hdr*)opt->srcrt; |
| 407 | /* Obsolete field, MBZ, when originated by us */ | 409 | irthdr->reserved = 0; |
| 408 | irthdr->bitmap = 0; | ||
| 409 | opt->srcrt->segments_left = n; | 410 | opt->srcrt->segments_left = n; |
| 410 | for (i=0; i<n; i++) | 411 | for (i=0; i<n; i++) |
| 411 | memcpy(irthdr->addr+i, rthdr->addr+(n-1-i), 16); | 412 | memcpy(irthdr->addr+i, rthdr->addr+(n-1-i), 16); |
| @@ -459,11 +460,10 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff) | |||
| 459 | IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); | 460 | IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); |
| 460 | goto drop; | 461 | goto drop; |
| 461 | } | 462 | } |
| 462 | if (pkt_len + sizeof(struct ipv6hdr) < skb->len) { | 463 | |
| 463 | __pskb_trim(skb, pkt_len + sizeof(struct ipv6hdr)); | 464 | if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) |
| 464 | if (skb->ip_summed == CHECKSUM_HW) | 465 | goto drop; |
| 465 | skb->ip_summed = CHECKSUM_NONE; | 466 | |
| 466 | } | ||
| 467 | return 1; | 467 | return 1; |
| 468 | 468 | ||
| 469 | drop: | 469 | drop: |
| @@ -539,10 +539,15 @@ void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt, | |||
| 539 | u8 *proto, | 539 | u8 *proto, |
| 540 | struct in6_addr **daddr) | 540 | struct in6_addr **daddr) |
| 541 | { | 541 | { |
| 542 | if (opt->srcrt) | 542 | if (opt->srcrt) { |
| 543 | ipv6_push_rthdr(skb, proto, opt->srcrt, daddr); | 543 | ipv6_push_rthdr(skb, proto, opt->srcrt, daddr); |
| 544 | if (opt->dst0opt) | 544 | /* |
| 545 | ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt); | 545 | * IPV6_RTHDRDSTOPTS is ignored |
| 546 | * unless IPV6_RTHDR is set (RFC3542). | ||
| 547 | */ | ||
| 548 | if (opt->dst0opt) | ||
| 549 | ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt); | ||
| 550 | } | ||
| 546 | if (opt->hopopt) | 551 | if (opt->hopopt) |
| 547 | ipv6_push_exthdr(skb, proto, NEXTHDR_HOP, opt->hopopt); | 552 | ipv6_push_exthdr(skb, proto, NEXTHDR_HOP, opt->hopopt); |
| 548 | } | 553 | } |
| @@ -573,3 +578,97 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt) | |||
| 573 | } | 578 | } |
| 574 | return opt2; | 579 | return opt2; |
| 575 | } | 580 | } |
| 581 | |||
| 582 | static int ipv6_renew_option(void *ohdr, | ||
| 583 | struct ipv6_opt_hdr __user *newopt, int newoptlen, | ||
| 584 | int inherit, | ||
| 585 | struct ipv6_opt_hdr **hdr, | ||
| 586 | char **p) | ||
| 587 | { | ||
| 588 | if (inherit) { | ||
| 589 | if (ohdr) { | ||
| 590 | memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr)); | ||
| 591 | *hdr = (struct ipv6_opt_hdr *)*p; | ||
| 592 | *p += CMSG_ALIGN(ipv6_optlen(*(struct ipv6_opt_hdr **)hdr)); | ||
| 593 | } | ||
| 594 | } else { | ||
| 595 | if (newopt) { | ||
| 596 | if (copy_from_user(*p, newopt, newoptlen)) | ||
| 597 | return -EFAULT; | ||
| 598 | *hdr = (struct ipv6_opt_hdr *)*p; | ||
| 599 | if (ipv6_optlen(*(struct ipv6_opt_hdr **)hdr) > newoptlen) | ||
| 600 | return -EINVAL; | ||
| 601 | *p += CMSG_ALIGN(newoptlen); | ||
| 602 | } | ||
| 603 | } | ||
| 604 | return 0; | ||
| 605 | } | ||
| 606 | |||
| 607 | struct ipv6_txoptions * | ||
| 608 | ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt, | ||
| 609 | int newtype, | ||
| 610 | struct ipv6_opt_hdr __user *newopt, int newoptlen) | ||
| 611 | { | ||
| 612 | int tot_len = 0; | ||
| 613 | char *p; | ||
| 614 | struct ipv6_txoptions *opt2; | ||
| 615 | int err; | ||
| 616 | |||
| 617 | if (newtype != IPV6_HOPOPTS && opt->hopopt) | ||
| 618 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt)); | ||
| 619 | if (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt) | ||
| 620 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt)); | ||
| 621 | if (newtype != IPV6_RTHDR && opt->srcrt) | ||
| 622 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt)); | ||
| 623 | if (newtype != IPV6_DSTOPTS && opt->dst1opt) | ||
| 624 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt)); | ||
| 625 | if (newopt && newoptlen) | ||
| 626 | tot_len += CMSG_ALIGN(newoptlen); | ||
| 627 | |||
| 628 | if (!tot_len) | ||
| 629 | return NULL; | ||
| 630 | |||
| 631 | opt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC); | ||
| 632 | if (!opt2) | ||
| 633 | return ERR_PTR(-ENOBUFS); | ||
| 634 | |||
| 635 | memset(opt2, 0, tot_len); | ||
| 636 | |||
| 637 | opt2->tot_len = tot_len; | ||
| 638 | p = (char *)(opt2 + 1); | ||
| 639 | |||
| 640 | err = ipv6_renew_option(opt->hopopt, newopt, newoptlen, | ||
| 641 | newtype != IPV6_HOPOPTS, | ||
| 642 | &opt2->hopopt, &p); | ||
| 643 | if (err) | ||
| 644 | goto out; | ||
| 645 | |||
| 646 | err = ipv6_renew_option(opt->dst0opt, newopt, newoptlen, | ||
| 647 | newtype != IPV6_RTHDRDSTOPTS, | ||
| 648 | &opt2->dst0opt, &p); | ||
| 649 | if (err) | ||
| 650 | goto out; | ||
| 651 | |||
| 652 | err = ipv6_renew_option(opt->srcrt, newopt, newoptlen, | ||
| 653 | newtype != IPV6_RTHDR, | ||
| 654 | (struct ipv6_opt_hdr **)opt2->srcrt, &p); | ||
| 655 | if (err) | ||
| 656 | goto out; | ||
| 657 | |||
| 658 | err = ipv6_renew_option(opt->dst1opt, newopt, newoptlen, | ||
| 659 | newtype != IPV6_DSTOPTS, | ||
| 660 | &opt2->dst1opt, &p); | ||
| 661 | if (err) | ||
| 662 | goto out; | ||
| 663 | |||
| 664 | opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) + | ||
| 665 | (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) + | ||
| 666 | (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0); | ||
| 667 | opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0); | ||
| 668 | |||
| 669 | return opt2; | ||
| 670 | out: | ||
| 671 | sock_kfree_s(sk, p, tot_len); | ||
| 672 | return ERR_PTR(err); | ||
| 673 | } | ||
| 674 | |||
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index fa8f1bb0aa52..b7185fb3377c 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
| @@ -287,7 +287,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 287 | int iif = 0; | 287 | int iif = 0; |
| 288 | int addr_type = 0; | 288 | int addr_type = 0; |
| 289 | int len; | 289 | int len; |
| 290 | int hlimit; | 290 | int hlimit, tclass; |
| 291 | int err = 0; | 291 | int err = 0; |
| 292 | 292 | ||
| 293 | if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail) | 293 | if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail) |
| @@ -374,7 +374,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 374 | if (err) | 374 | if (err) |
| 375 | goto out; | 375 | goto out; |
| 376 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) | 376 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 377 | goto out_dst_release; | 377 | goto out; |
| 378 | 378 | ||
| 379 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 379 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
| 380 | hlimit = np->mcast_hops; | 380 | hlimit = np->mcast_hops; |
| @@ -385,6 +385,10 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 385 | if (hlimit < 0) | 385 | if (hlimit < 0) |
| 386 | hlimit = ipv6_get_hoplimit(dst->dev); | 386 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 387 | 387 | ||
| 388 | tclass = np->cork.tclass; | ||
| 389 | if (tclass < 0) | ||
| 390 | tclass = 0; | ||
| 391 | |||
| 388 | msg.skb = skb; | 392 | msg.skb = skb; |
| 389 | msg.offset = skb->nh.raw - skb->data; | 393 | msg.offset = skb->nh.raw - skb->data; |
| 390 | 394 | ||
| @@ -400,7 +404,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 400 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, | 404 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, |
| 401 | len + sizeof(struct icmp6hdr), | 405 | len + sizeof(struct icmp6hdr), |
| 402 | sizeof(struct icmp6hdr), | 406 | sizeof(struct icmp6hdr), |
| 403 | hlimit, NULL, &fl, (struct rt6_info*)dst, | 407 | hlimit, tclass, NULL, &fl, (struct rt6_info*)dst, |
| 404 | MSG_DONTWAIT); | 408 | MSG_DONTWAIT); |
| 405 | if (err) { | 409 | if (err) { |
| 406 | ip6_flush_pending_frames(sk); | 410 | ip6_flush_pending_frames(sk); |
| @@ -434,6 +438,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 434 | struct dst_entry *dst; | 438 | struct dst_entry *dst; |
| 435 | int err = 0; | 439 | int err = 0; |
| 436 | int hlimit; | 440 | int hlimit; |
| 441 | int tclass; | ||
| 437 | 442 | ||
| 438 | saddr = &skb->nh.ipv6h->daddr; | 443 | saddr = &skb->nh.ipv6h->daddr; |
| 439 | 444 | ||
| @@ -464,7 +469,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 464 | if (err) | 469 | if (err) |
| 465 | goto out; | 470 | goto out; |
| 466 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) | 471 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 467 | goto out_dst_release; | 472 | goto out; |
| 468 | 473 | ||
| 469 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 474 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
| 470 | hlimit = np->mcast_hops; | 475 | hlimit = np->mcast_hops; |
| @@ -475,13 +480,17 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 475 | if (hlimit < 0) | 480 | if (hlimit < 0) |
| 476 | hlimit = ipv6_get_hoplimit(dst->dev); | 481 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 477 | 482 | ||
| 483 | tclass = np->cork.tclass; | ||
| 484 | if (tclass < 0) | ||
| 485 | tclass = 0; | ||
| 486 | |||
| 478 | idev = in6_dev_get(skb->dev); | 487 | idev = in6_dev_get(skb->dev); |
| 479 | 488 | ||
| 480 | msg.skb = skb; | 489 | msg.skb = skb; |
| 481 | msg.offset = 0; | 490 | msg.offset = 0; |
| 482 | 491 | ||
| 483 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), | 492 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), |
| 484 | sizeof(struct icmp6hdr), hlimit, NULL, &fl, | 493 | sizeof(struct icmp6hdr), hlimit, tclass, NULL, &fl, |
| 485 | (struct rt6_info*)dst, MSG_DONTWAIT); | 494 | (struct rt6_info*)dst, MSG_DONTWAIT); |
| 486 | 495 | ||
| 487 | if (err) { | 496 | if (err) { |
| @@ -496,7 +505,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 496 | out_put: | 505 | out_put: |
| 497 | if (likely(idev != NULL)) | 506 | if (likely(idev != NULL)) |
| 498 | in6_dev_put(idev); | 507 | in6_dev_put(idev); |
| 499 | out_dst_release: | ||
| 500 | dst_release(dst); | 508 | dst_release(dst); |
| 501 | out: | 509 | out: |
| 502 | icmpv6_xmit_unlock(); | 510 | icmpv6_xmit_unlock(); |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 16af874c9e8f..4fcc5a7acf6e 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
| @@ -92,7 +92,7 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn); | |||
| 92 | 92 | ||
| 93 | static __u32 rt_sernum; | 93 | static __u32 rt_sernum; |
| 94 | 94 | ||
| 95 | static struct timer_list ip6_fib_timer = TIMER_INITIALIZER(fib6_run_gc, 0, 0); | 95 | static DEFINE_TIMER(ip6_fib_timer, fib6_run_gc, 0, 0); |
| 96 | 96 | ||
| 97 | struct fib6_walker_t fib6_walker_list = { | 97 | struct fib6_walker_t fib6_walker_list = { |
| 98 | .prev = &fib6_walker_list, | 98 | .prev = &fib6_walker_list, |
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index b6c73da5ff35..f841bde30c18 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c | |||
| @@ -50,7 +50,7 @@ static atomic_t fl_size = ATOMIC_INIT(0); | |||
| 50 | static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1]; | 50 | static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1]; |
| 51 | 51 | ||
| 52 | static void ip6_fl_gc(unsigned long dummy); | 52 | static void ip6_fl_gc(unsigned long dummy); |
| 53 | static struct timer_list ip6_fl_gc_timer = TIMER_INITIALIZER(ip6_fl_gc, 0, 0); | 53 | static DEFINE_TIMER(ip6_fl_gc_timer, ip6_fl_gc, 0, 0); |
| 54 | 54 | ||
| 55 | /* FL hash table lock: it protects only of GC */ | 55 | /* FL hash table lock: it protects only of GC */ |
| 56 | 56 | ||
| @@ -225,16 +225,20 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space, | |||
| 225 | struct ip6_flowlabel * fl, | 225 | struct ip6_flowlabel * fl, |
| 226 | struct ipv6_txoptions * fopt) | 226 | struct ipv6_txoptions * fopt) |
| 227 | { | 227 | { |
| 228 | struct ipv6_txoptions * fl_opt = fl->opt; | 228 | struct ipv6_txoptions * fl_opt = fl ? fl->opt : NULL; |
| 229 | 229 | ||
| 230 | if (fopt == NULL || fopt->opt_flen == 0) | 230 | if (fopt == NULL || fopt->opt_flen == 0) { |
| 231 | return fl_opt; | 231 | if (!fl_opt || !fl_opt->dst0opt || fl_opt->srcrt) |
| 232 | return fl_opt; | ||
| 233 | } | ||
| 232 | 234 | ||
| 233 | if (fl_opt != NULL) { | 235 | if (fl_opt != NULL) { |
| 234 | opt_space->hopopt = fl_opt->hopopt; | 236 | opt_space->hopopt = fl_opt->hopopt; |
| 235 | opt_space->dst0opt = fl_opt->dst0opt; | 237 | opt_space->dst0opt = fl_opt->srcrt ? fl_opt->dst0opt : NULL; |
| 236 | opt_space->srcrt = fl_opt->srcrt; | 238 | opt_space->srcrt = fl_opt->srcrt; |
| 237 | opt_space->opt_nflen = fl_opt->opt_nflen; | 239 | opt_space->opt_nflen = fl_opt->opt_nflen; |
| 240 | if (fl_opt->dst0opt && !fl_opt->srcrt) | ||
| 241 | opt_space->opt_nflen -= ipv6_optlen(fl_opt->dst0opt); | ||
| 238 | } else { | 242 | } else { |
| 239 | if (fopt->opt_nflen == 0) | 243 | if (fopt->opt_nflen == 0) |
| 240 | return fopt; | 244 | return fopt; |
| @@ -310,7 +314,7 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int * | |||
| 310 | msg.msg_control = (void*)(fl->opt+1); | 314 | msg.msg_control = (void*)(fl->opt+1); |
| 311 | flowi.oif = 0; | 315 | flowi.oif = 0; |
| 312 | 316 | ||
| 313 | err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk); | 317 | err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk, &junk); |
| 314 | if (err) | 318 | if (err) |
| 315 | goto done; | 319 | goto done; |
| 316 | err = -EINVAL; | 320 | err = -EINVAL; |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 01ef94f7c7f1..2f589f24c093 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -166,7 +166,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
| 166 | struct ipv6hdr *hdr; | 166 | struct ipv6hdr *hdr; |
| 167 | u8 proto = fl->proto; | 167 | u8 proto = fl->proto; |
| 168 | int seg_len = skb->len; | 168 | int seg_len = skb->len; |
| 169 | int hlimit; | 169 | int hlimit, tclass; |
| 170 | u32 mtu; | 170 | u32 mtu; |
| 171 | 171 | ||
| 172 | if (opt) { | 172 | if (opt) { |
| @@ -202,7 +202,6 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
| 202 | * Fill in the IPv6 header | 202 | * Fill in the IPv6 header |
| 203 | */ | 203 | */ |
| 204 | 204 | ||
| 205 | *(u32*)hdr = htonl(0x60000000) | fl->fl6_flowlabel; | ||
| 206 | hlimit = -1; | 205 | hlimit = -1; |
| 207 | if (np) | 206 | if (np) |
| 208 | hlimit = np->hop_limit; | 207 | hlimit = np->hop_limit; |
| @@ -211,6 +210,14 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
| 211 | if (hlimit < 0) | 210 | if (hlimit < 0) |
| 212 | hlimit = ipv6_get_hoplimit(dst->dev); | 211 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 213 | 212 | ||
| 213 | tclass = -1; | ||
| 214 | if (np) | ||
| 215 | tclass = np->tclass; | ||
| 216 | if (tclass < 0) | ||
| 217 | tclass = 0; | ||
| 218 | |||
| 219 | *(u32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel; | ||
| 220 | |||
| 214 | hdr->payload_len = htons(seg_len); | 221 | hdr->payload_len = htons(seg_len); |
| 215 | hdr->nexthdr = proto; | 222 | hdr->nexthdr = proto; |
| 216 | hdr->hop_limit = hlimit; | 223 | hdr->hop_limit = hlimit; |
| @@ -762,10 +769,11 @@ out_err_release: | |||
| 762 | return err; | 769 | return err; |
| 763 | } | 770 | } |
| 764 | 771 | ||
| 765 | int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), | 772 | int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, |
| 766 | void *from, int length, int transhdrlen, | 773 | int offset, int len, int odd, struct sk_buff *skb), |
| 767 | int hlimit, struct ipv6_txoptions *opt, struct flowi *fl, struct rt6_info *rt, | 774 | void *from, int length, int transhdrlen, |
| 768 | unsigned int flags) | 775 | int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl, |
| 776 | struct rt6_info *rt, unsigned int flags) | ||
| 769 | { | 777 | { |
| 770 | struct inet_sock *inet = inet_sk(sk); | 778 | struct inet_sock *inet = inet_sk(sk); |
| 771 | struct ipv6_pinfo *np = inet6_sk(sk); | 779 | struct ipv6_pinfo *np = inet6_sk(sk); |
| @@ -803,6 +811,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offse | |||
| 803 | np->cork.rt = rt; | 811 | np->cork.rt = rt; |
| 804 | inet->cork.fl = *fl; | 812 | inet->cork.fl = *fl; |
| 805 | np->cork.hop_limit = hlimit; | 813 | np->cork.hop_limit = hlimit; |
| 814 | np->cork.tclass = tclass; | ||
| 806 | inet->cork.fragsize = mtu = dst_mtu(rt->u.dst.path); | 815 | inet->cork.fragsize = mtu = dst_mtu(rt->u.dst.path); |
| 807 | if (dst_allfrag(rt->u.dst.path)) | 816 | if (dst_allfrag(rt->u.dst.path)) |
| 808 | inet->cork.flags |= IPCORK_ALLFRAG; | 817 | inet->cork.flags |= IPCORK_ALLFRAG; |
| @@ -1084,7 +1093,8 @@ int ip6_push_pending_frames(struct sock *sk) | |||
| 1084 | 1093 | ||
| 1085 | skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); | 1094 | skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); |
| 1086 | 1095 | ||
| 1087 | *(u32*)hdr = fl->fl6_flowlabel | htonl(0x60000000); | 1096 | *(u32*)hdr = fl->fl6_flowlabel | |
| 1097 | htonl(0x60000000 | ((int)np->cork.tclass << 20)); | ||
| 1088 | 1098 | ||
| 1089 | if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) | 1099 | if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) |
| 1090 | hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); | 1100 | hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 09613729404c..cf94372d1af3 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
| @@ -673,11 +673,12 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 673 | 673 | ||
| 674 | if ((dst = ip6_tnl_dst_check(t)) != NULL) | 674 | if ((dst = ip6_tnl_dst_check(t)) != NULL) |
| 675 | dst_hold(dst); | 675 | dst_hold(dst); |
| 676 | else | 676 | else { |
| 677 | dst = ip6_route_output(NULL, &fl); | 677 | dst = ip6_route_output(NULL, &fl); |
| 678 | 678 | ||
| 679 | if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0) | 679 | if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0) |
| 680 | goto tx_err_link_failure; | 680 | goto tx_err_link_failure; |
| 681 | } | ||
| 681 | 682 | ||
| 682 | tdev = dst->dev; | 683 | tdev = dst->dev; |
| 683 | 684 | ||
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 76466af8331e..8567873d0dd8 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
| @@ -210,39 +210,139 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
| 210 | retv = 0; | 210 | retv = 0; |
| 211 | break; | 211 | break; |
| 212 | 212 | ||
| 213 | case IPV6_PKTINFO: | 213 | case IPV6_RECVPKTINFO: |
| 214 | np->rxopt.bits.rxinfo = valbool; | 214 | np->rxopt.bits.rxinfo = valbool; |
| 215 | retv = 0; | 215 | retv = 0; |
| 216 | break; | 216 | break; |
| 217 | |||
| 218 | case IPV6_2292PKTINFO: | ||
| 219 | np->rxopt.bits.rxoinfo = valbool; | ||
| 220 | retv = 0; | ||
| 221 | break; | ||
| 217 | 222 | ||
| 218 | case IPV6_HOPLIMIT: | 223 | case IPV6_RECVHOPLIMIT: |
| 219 | np->rxopt.bits.rxhlim = valbool; | 224 | np->rxopt.bits.rxhlim = valbool; |
| 220 | retv = 0; | 225 | retv = 0; |
| 221 | break; | 226 | break; |
| 222 | 227 | ||
| 223 | case IPV6_RTHDR: | 228 | case IPV6_2292HOPLIMIT: |
| 229 | np->rxopt.bits.rxohlim = valbool; | ||
| 230 | retv = 0; | ||
| 231 | break; | ||
| 232 | |||
| 233 | case IPV6_RECVRTHDR: | ||
| 224 | if (val < 0 || val > 2) | 234 | if (val < 0 || val > 2) |
| 225 | goto e_inval; | 235 | goto e_inval; |
| 226 | np->rxopt.bits.srcrt = val; | 236 | np->rxopt.bits.srcrt = val; |
| 227 | retv = 0; | 237 | retv = 0; |
| 228 | break; | 238 | break; |
| 229 | 239 | ||
| 230 | case IPV6_HOPOPTS: | 240 | case IPV6_2292RTHDR: |
| 241 | if (val < 0 || val > 2) | ||
| 242 | goto e_inval; | ||
| 243 | np->rxopt.bits.osrcrt = val; | ||
| 244 | retv = 0; | ||
| 245 | break; | ||
| 246 | |||
| 247 | case IPV6_RECVHOPOPTS: | ||
| 231 | np->rxopt.bits.hopopts = valbool; | 248 | np->rxopt.bits.hopopts = valbool; |
| 232 | retv = 0; | 249 | retv = 0; |
| 233 | break; | 250 | break; |
| 234 | 251 | ||
| 235 | case IPV6_DSTOPTS: | 252 | case IPV6_2292HOPOPTS: |
| 253 | np->rxopt.bits.ohopopts = valbool; | ||
| 254 | retv = 0; | ||
| 255 | break; | ||
| 256 | |||
| 257 | case IPV6_RECVDSTOPTS: | ||
| 236 | np->rxopt.bits.dstopts = valbool; | 258 | np->rxopt.bits.dstopts = valbool; |
| 237 | retv = 0; | 259 | retv = 0; |
| 238 | break; | 260 | break; |
| 239 | 261 | ||
| 262 | case IPV6_2292DSTOPTS: | ||
| 263 | np->rxopt.bits.odstopts = valbool; | ||
| 264 | retv = 0; | ||
| 265 | break; | ||
| 266 | |||
| 267 | case IPV6_TCLASS: | ||
| 268 | if (val < 0 || val > 0xff) | ||
| 269 | goto e_inval; | ||
| 270 | np->tclass = val; | ||
| 271 | retv = 0; | ||
| 272 | break; | ||
| 273 | |||
| 274 | case IPV6_RECVTCLASS: | ||
| 275 | np->rxopt.bits.rxtclass = valbool; | ||
| 276 | retv = 0; | ||
| 277 | break; | ||
| 278 | |||
| 240 | case IPV6_FLOWINFO: | 279 | case IPV6_FLOWINFO: |
| 241 | np->rxopt.bits.rxflow = valbool; | 280 | np->rxopt.bits.rxflow = valbool; |
| 242 | retv = 0; | 281 | retv = 0; |
| 243 | break; | 282 | break; |
| 244 | 283 | ||
| 245 | case IPV6_PKTOPTIONS: | 284 | case IPV6_HOPOPTS: |
| 285 | case IPV6_RTHDRDSTOPTS: | ||
| 286 | case IPV6_RTHDR: | ||
| 287 | case IPV6_DSTOPTS: | ||
| 288 | { | ||
| 289 | struct ipv6_txoptions *opt; | ||
| 290 | if (optlen == 0) | ||
| 291 | optval = 0; | ||
| 292 | |||
| 293 | /* hop-by-hop / destination options are privileged option */ | ||
| 294 | retv = -EPERM; | ||
| 295 | if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW)) | ||
| 296 | break; | ||
| 297 | |||
| 298 | retv = -EINVAL; | ||
| 299 | if (optlen & 0x7 || optlen > 8 * 255) | ||
| 300 | break; | ||
| 301 | |||
| 302 | opt = ipv6_renew_options(sk, np->opt, optname, | ||
| 303 | (struct ipv6_opt_hdr __user *)optval, | ||
| 304 | optlen); | ||
| 305 | if (IS_ERR(opt)) { | ||
| 306 | retv = PTR_ERR(opt); | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | |||
| 310 | /* routing header option needs extra check */ | ||
| 311 | if (optname == IPV6_RTHDR && opt->srcrt) { | ||
| 312 | struct ipv6_rt_hdr *rthdr = opt->srcrt; | ||
| 313 | if (rthdr->type) | ||
| 314 | goto sticky_done; | ||
| 315 | if ((rthdr->hdrlen & 1) || | ||
| 316 | (rthdr->hdrlen >> 1) != rthdr->segments_left) | ||
| 317 | goto sticky_done; | ||
| 318 | } | ||
| 319 | |||
| 320 | retv = 0; | ||
| 321 | if (sk->sk_type == SOCK_STREAM) { | ||
| 322 | if (opt) { | ||
| 323 | struct tcp_sock *tp = tcp_sk(sk); | ||
| 324 | if (!((1 << sk->sk_state) & | ||
| 325 | (TCPF_LISTEN | TCPF_CLOSE)) | ||
| 326 | && inet_sk(sk)->daddr != LOOPBACK4_IPV6) { | ||
| 327 | tp->ext_header_len = opt->opt_flen + opt->opt_nflen; | ||
| 328 | tcp_sync_mss(sk, tp->pmtu_cookie); | ||
| 329 | } | ||
| 330 | } | ||
| 331 | opt = xchg(&np->opt, opt); | ||
| 332 | sk_dst_reset(sk); | ||
| 333 | } else { | ||
| 334 | write_lock(&sk->sk_dst_lock); | ||
| 335 | opt = xchg(&np->opt, opt); | ||
| 336 | write_unlock(&sk->sk_dst_lock); | ||
| 337 | sk_dst_reset(sk); | ||
| 338 | } | ||
| 339 | sticky_done: | ||
| 340 | if (opt) | ||
| 341 | sock_kfree_s(sk, opt, opt->tot_len); | ||
| 342 | break; | ||
| 343 | } | ||
| 344 | |||
| 345 | case IPV6_2292PKTOPTIONS: | ||
| 246 | { | 346 | { |
| 247 | struct ipv6_txoptions *opt = NULL; | 347 | struct ipv6_txoptions *opt = NULL; |
| 248 | struct msghdr msg; | 348 | struct msghdr msg; |
| @@ -276,7 +376,7 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
| 276 | msg.msg_controllen = optlen; | 376 | msg.msg_controllen = optlen; |
| 277 | msg.msg_control = (void*)(opt+1); | 377 | msg.msg_control = (void*)(opt+1); |
| 278 | 378 | ||
| 279 | retv = datagram_send_ctl(&msg, &fl, opt, &junk); | 379 | retv = datagram_send_ctl(&msg, &fl, opt, &junk, &junk); |
| 280 | if (retv) | 380 | if (retv) |
| 281 | goto done; | 381 | goto done; |
| 282 | update: | 382 | update: |
| @@ -529,6 +629,17 @@ e_inval: | |||
| 529 | return -EINVAL; | 629 | return -EINVAL; |
| 530 | } | 630 | } |
| 531 | 631 | ||
| 632 | int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr, | ||
| 633 | char __user *optval, int len) | ||
| 634 | { | ||
| 635 | if (!hdr) | ||
| 636 | return 0; | ||
| 637 | len = min_t(int, len, ipv6_optlen(hdr)); | ||
| 638 | if (copy_to_user(optval, hdr, ipv6_optlen(hdr))) | ||
| 639 | return -EFAULT; | ||
| 640 | return len; | ||
| 641 | } | ||
| 642 | |||
| 532 | int ipv6_getsockopt(struct sock *sk, int level, int optname, | 643 | int ipv6_getsockopt(struct sock *sk, int level, int optname, |
| 533 | char __user *optval, int __user *optlen) | 644 | char __user *optval, int __user *optlen) |
| 534 | { | 645 | { |
| @@ -567,7 +678,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 567 | return err; | 678 | return err; |
| 568 | } | 679 | } |
| 569 | 680 | ||
| 570 | case IPV6_PKTOPTIONS: | 681 | case IPV6_2292PKTOPTIONS: |
| 571 | { | 682 | { |
| 572 | struct msghdr msg; | 683 | struct msghdr msg; |
| 573 | struct sk_buff *skb; | 684 | struct sk_buff *skb; |
| @@ -601,6 +712,16 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 601 | int hlim = np->mcast_hops; | 712 | int hlim = np->mcast_hops; |
| 602 | put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); | 713 | put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); |
| 603 | } | 714 | } |
| 715 | if (np->rxopt.bits.rxoinfo) { | ||
| 716 | struct in6_pktinfo src_info; | ||
| 717 | src_info.ipi6_ifindex = np->mcast_oif; | ||
| 718 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); | ||
| 719 | put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); | ||
| 720 | } | ||
| 721 | if (np->rxopt.bits.rxohlim) { | ||
| 722 | int hlim = np->mcast_hops; | ||
| 723 | put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); | ||
| 724 | } | ||
| 604 | } | 725 | } |
| 605 | len -= msg.msg_controllen; | 726 | len -= msg.msg_controllen; |
| 606 | return put_user(len, optlen); | 727 | return put_user(len, optlen); |
| @@ -625,26 +746,67 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 625 | val = np->ipv6only; | 746 | val = np->ipv6only; |
| 626 | break; | 747 | break; |
| 627 | 748 | ||
| 628 | case IPV6_PKTINFO: | 749 | case IPV6_RECVPKTINFO: |
| 629 | val = np->rxopt.bits.rxinfo; | 750 | val = np->rxopt.bits.rxinfo; |
| 630 | break; | 751 | break; |
| 631 | 752 | ||
| 632 | case IPV6_HOPLIMIT: | 753 | case IPV6_2292PKTINFO: |
| 754 | val = np->rxopt.bits.rxoinfo; | ||
| 755 | break; | ||
| 756 | |||
| 757 | case IPV6_RECVHOPLIMIT: | ||
| 633 | val = np->rxopt.bits.rxhlim; | 758 | val = np->rxopt.bits.rxhlim; |
| 634 | break; | 759 | break; |
| 635 | 760 | ||
| 636 | case IPV6_RTHDR: | 761 | case IPV6_2292HOPLIMIT: |
| 762 | val = np->rxopt.bits.rxohlim; | ||
| 763 | break; | ||
| 764 | |||
| 765 | case IPV6_RECVRTHDR: | ||
| 637 | val = np->rxopt.bits.srcrt; | 766 | val = np->rxopt.bits.srcrt; |
| 638 | break; | 767 | break; |
| 639 | 768 | ||
| 769 | case IPV6_2292RTHDR: | ||
| 770 | val = np->rxopt.bits.osrcrt; | ||
| 771 | break; | ||
| 772 | |||
| 640 | case IPV6_HOPOPTS: | 773 | case IPV6_HOPOPTS: |
| 774 | case IPV6_RTHDRDSTOPTS: | ||
| 775 | case IPV6_RTHDR: | ||
| 776 | case IPV6_DSTOPTS: | ||
| 777 | { | ||
| 778 | |||
| 779 | lock_sock(sk); | ||
| 780 | len = ipv6_getsockopt_sticky(sk, np->opt->hopopt, | ||
| 781 | optval, len); | ||
| 782 | release_sock(sk); | ||
| 783 | return put_user(len, optlen); | ||
| 784 | } | ||
| 785 | |||
| 786 | case IPV6_RECVHOPOPTS: | ||
| 641 | val = np->rxopt.bits.hopopts; | 787 | val = np->rxopt.bits.hopopts; |
| 642 | break; | 788 | break; |
| 643 | 789 | ||
| 644 | case IPV6_DSTOPTS: | 790 | case IPV6_2292HOPOPTS: |
| 791 | val = np->rxopt.bits.ohopopts; | ||
| 792 | break; | ||
| 793 | |||
| 794 | case IPV6_RECVDSTOPTS: | ||
| 645 | val = np->rxopt.bits.dstopts; | 795 | val = np->rxopt.bits.dstopts; |
| 646 | break; | 796 | break; |
| 647 | 797 | ||
| 798 | case IPV6_2292DSTOPTS: | ||
| 799 | val = np->rxopt.bits.odstopts; | ||
| 800 | break; | ||
| 801 | |||
| 802 | case IPV6_TCLASS: | ||
| 803 | val = np->tclass; | ||
| 804 | break; | ||
| 805 | |||
| 806 | case IPV6_RECVTCLASS: | ||
| 807 | val = np->rxopt.bits.rxtclass; | ||
| 808 | break; | ||
| 809 | |||
| 648 | case IPV6_FLOWINFO: | 810 | case IPV6_FLOWINFO: |
| 649 | val = np->rxopt.bits.rxflow; | 811 | val = np->rxopt.bits.rxflow; |
| 650 | break; | 812 | break; |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index a7eae30f4554..555a31347eda 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
| @@ -447,10 +447,8 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, | |||
| 447 | return; | 447 | return; |
| 448 | 448 | ||
| 449 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 449 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 450 | if (err < 0) { | 450 | if (err < 0) |
| 451 | dst_release(dst); | ||
| 452 | return; | 451 | return; |
| 453 | } | ||
| 454 | 452 | ||
| 455 | if (inc_opt) { | 453 | if (inc_opt) { |
| 456 | if (dev->addr_len) | 454 | if (dev->addr_len) |
| @@ -539,10 +537,8 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh, | |||
| 539 | return; | 537 | return; |
| 540 | 538 | ||
| 541 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 539 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 542 | if (err < 0) { | 540 | if (err < 0) |
| 543 | dst_release(dst); | ||
| 544 | return; | 541 | return; |
| 545 | } | ||
| 546 | 542 | ||
| 547 | len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); | 543 | len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); |
| 548 | send_llinfo = dev->addr_len && !ipv6_addr_any(saddr); | 544 | send_llinfo = dev->addr_len && !ipv6_addr_any(saddr); |
| @@ -616,10 +612,8 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr, | |||
| 616 | return; | 612 | return; |
| 617 | 613 | ||
| 618 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 614 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 619 | if (err < 0) { | 615 | if (err < 0) |
| 620 | dst_release(dst); | ||
| 621 | return; | 616 | return; |
| 622 | } | ||
| 623 | 617 | ||
| 624 | len = sizeof(struct icmp6hdr); | 618 | len = sizeof(struct icmp6hdr); |
| 625 | if (dev->addr_len) | 619 | if (dev->addr_len) |
| @@ -1353,10 +1347,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, | |||
| 1353 | return; | 1347 | return; |
| 1354 | 1348 | ||
| 1355 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 1349 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 1356 | if (err) { | 1350 | if (err) |
| 1357 | dst_release(dst); | ||
| 1358 | return; | 1351 | return; |
| 1359 | } | ||
| 1360 | 1352 | ||
| 1361 | rt = (struct rt6_info *) dst; | 1353 | rt = (struct rt6_info *) dst; |
| 1362 | 1354 | ||
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index 14316c3ebde4..b03e87adca93 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
| @@ -100,11 +100,8 @@ static void send_reset(struct sk_buff *oldskb) | |||
| 100 | dst = ip6_route_output(NULL, &fl); | 100 | dst = ip6_route_output(NULL, &fl); |
| 101 | if (dst == NULL) | 101 | if (dst == NULL) |
| 102 | return; | 102 | return; |
| 103 | if (dst->error || | 103 | if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0)) |
| 104 | xfrm_lookup(&dst, &fl, NULL, 0)) { | ||
| 105 | dst_release(dst); | ||
| 106 | return; | 104 | return; |
| 107 | } | ||
| 108 | 105 | ||
| 109 | hh_len = (dst->dev->hard_header_len + 15)&~15; | 106 | hh_len = (dst->dev->hard_header_len + 15)&~15; |
| 110 | nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr) | 107 | nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr) |
diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c index 9b91decbfddb..4de4cdad4b7d 100644 --- a/net/ipv6/netfilter/ip6t_owner.c +++ b/net/ipv6/netfilter/ip6t_owner.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/skbuff.h> | 12 | #include <linux/skbuff.h> |
| 13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
| 14 | #include <linux/rcupdate.h> | ||
| 14 | #include <net/sock.h> | 15 | #include <net/sock.h> |
| 15 | 16 | ||
| 16 | #include <linux/netfilter_ipv6/ip6t_owner.h> | 17 | #include <linux/netfilter_ipv6/ip6t_owner.h> |
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c index a9526b773d28..2bb670037df3 100644 --- a/net/ipv6/netfilter/ip6t_rt.c +++ b/net/ipv6/netfilter/ip6t_rt.c | |||
| @@ -161,8 +161,8 @@ match(const struct sk_buff *skb, | |||
| 161 | ((rtinfo->hdrlen == hdrlen) ^ | 161 | ((rtinfo->hdrlen == hdrlen) ^ |
| 162 | !!(rtinfo->invflags & IP6T_RT_INV_LEN)))); | 162 | !!(rtinfo->invflags & IP6T_RT_INV_LEN)))); |
| 163 | DEBUGP("res %02X %02X %02X ", | 163 | DEBUGP("res %02X %02X %02X ", |
| 164 | (rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->bitmap, | 164 | (rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->reserved, |
| 165 | !((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->bitmap))); | 165 | !((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->reserved))); |
| 166 | 166 | ||
| 167 | ret = (rh != NULL) | 167 | ret = (rh != NULL) |
| 168 | && | 168 | && |
| @@ -179,12 +179,12 @@ match(const struct sk_buff *skb, | |||
| 179 | !!(rtinfo->invflags & IP6T_RT_INV_TYP))); | 179 | !!(rtinfo->invflags & IP6T_RT_INV_TYP))); |
| 180 | 180 | ||
| 181 | if (ret && (rtinfo->flags & IP6T_RT_RES)) { | 181 | if (ret && (rtinfo->flags & IP6T_RT_RES)) { |
| 182 | u_int32_t *bp, _bitmap; | 182 | u_int32_t *rp, _reserved; |
| 183 | bp = skb_header_pointer(skb, | 183 | rp = skb_header_pointer(skb, |
| 184 | ptr + offsetof(struct rt0_hdr, bitmap), | 184 | ptr + offsetof(struct rt0_hdr, reserved), |
| 185 | sizeof(_bitmap), &_bitmap); | 185 | sizeof(_reserved), &_reserved); |
| 186 | 186 | ||
| 187 | ret = (*bp == 0); | 187 | ret = (*rp == 0); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | DEBUGP("#%d ",rtinfo->addrnr); | 190 | DEBUGP("#%d ",rtinfo->addrnr); |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index ed3a76b30fd9..5aa3691c578d 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
| @@ -655,6 +655,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 655 | struct flowi fl; | 655 | struct flowi fl; |
| 656 | int addr_len = msg->msg_namelen; | 656 | int addr_len = msg->msg_namelen; |
| 657 | int hlimit = -1; | 657 | int hlimit = -1; |
| 658 | int tclass = -1; | ||
| 658 | u16 proto; | 659 | u16 proto; |
| 659 | int err; | 660 | int err; |
| 660 | 661 | ||
| @@ -740,7 +741,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 740 | memset(opt, 0, sizeof(struct ipv6_txoptions)); | 741 | memset(opt, 0, sizeof(struct ipv6_txoptions)); |
| 741 | opt->tot_len = sizeof(struct ipv6_txoptions); | 742 | opt->tot_len = sizeof(struct ipv6_txoptions); |
| 742 | 743 | ||
| 743 | err = datagram_send_ctl(msg, &fl, opt, &hlimit); | 744 | err = datagram_send_ctl(msg, &fl, opt, &hlimit, &tclass); |
| 744 | if (err < 0) { | 745 | if (err < 0) { |
| 745 | fl6_sock_release(flowlabel); | 746 | fl6_sock_release(flowlabel); |
| 746 | return err; | 747 | return err; |
| @@ -755,8 +756,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 755 | } | 756 | } |
| 756 | if (opt == NULL) | 757 | if (opt == NULL) |
| 757 | opt = np->opt; | 758 | opt = np->opt; |
| 758 | if (flowlabel) | 759 | opt = fl6_merge_options(&opt_space, flowlabel, opt); |
| 759 | opt = fl6_merge_options(&opt_space, flowlabel, opt); | ||
| 760 | 760 | ||
| 761 | fl.proto = proto; | 761 | fl.proto = proto; |
| 762 | rawv6_probe_proto_opt(&fl, msg); | 762 | rawv6_probe_proto_opt(&fl, msg); |
| @@ -782,10 +782,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 782 | if (final_p) | 782 | if (final_p) |
| 783 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 783 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
| 784 | 784 | ||
| 785 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 785 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 786 | dst_release(dst); | ||
| 787 | goto out; | 786 | goto out; |
| 788 | } | ||
| 789 | 787 | ||
| 790 | if (hlimit < 0) { | 788 | if (hlimit < 0) { |
| 791 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 789 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
| @@ -798,6 +796,12 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 798 | hlimit = ipv6_get_hoplimit(dst->dev); | 796 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 799 | } | 797 | } |
| 800 | 798 | ||
| 799 | if (tclass < 0) { | ||
| 800 | tclass = np->cork.tclass; | ||
| 801 | if (tclass < 0) | ||
| 802 | tclass = 0; | ||
| 803 | } | ||
| 804 | |||
| 801 | if (msg->msg_flags&MSG_CONFIRM) | 805 | if (msg->msg_flags&MSG_CONFIRM) |
| 802 | goto do_confirm; | 806 | goto do_confirm; |
| 803 | 807 | ||
| @@ -806,8 +810,9 @@ back_from_confirm: | |||
| 806 | err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags); | 810 | err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags); |
| 807 | } else { | 811 | } else { |
| 808 | lock_sock(sk); | 812 | lock_sock(sk); |
| 809 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0, | 813 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, |
| 810 | hlimit, opt, &fl, (struct rt6_info*)dst, msg->msg_flags); | 814 | len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst, |
| 815 | msg->msg_flags); | ||
| 811 | 816 | ||
| 812 | if (err) | 817 | if (err) |
| 813 | ip6_flush_pending_frames(sk); | 818 | ip6_flush_pending_frames(sk); |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 9d9e04344c77..e4fe9ee484dd 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
| @@ -479,12 +479,9 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, | |||
| 479 | /* Point into the IP datagram 'data' part. */ | 479 | /* Point into the IP datagram 'data' part. */ |
| 480 | if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) | 480 | if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) |
| 481 | goto err; | 481 | goto err; |
| 482 | if (end-offset < skb->len) { | 482 | |
| 483 | if (pskb_trim(skb, end - offset)) | 483 | if (pskb_trim_rcsum(skb, end - offset)) |
| 484 | goto err; | 484 | goto err; |
| 485 | if (skb->ip_summed != CHECKSUM_UNNECESSARY) | ||
| 486 | skb->ip_summed = CHECKSUM_NONE; | ||
| 487 | } | ||
| 488 | 485 | ||
| 489 | /* Find out which fragments are in front and at the back of us | 486 | /* Find out which fragments are in front and at the back of us |
| 490 | * in the chain of fragments so far. We must know where to put | 487 | * in the chain of fragments so far. We must know where to put |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 794734f1d230..80643e6b346b 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -632,10 +632,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
| 632 | if (final_p) | 632 | if (final_p) |
| 633 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 633 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
| 634 | 634 | ||
| 635 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 635 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 636 | dst_release(dst); | ||
| 637 | goto failure; | 636 | goto failure; |
| 638 | } | ||
| 639 | 637 | ||
| 640 | if (saddr == NULL) { | 638 | if (saddr == NULL) { |
| 641 | saddr = &fl.fl6_src; | 639 | saddr = &fl.fl6_src; |
| @@ -849,7 +847,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, | |||
| 849 | if (dst == NULL) { | 847 | if (dst == NULL) { |
| 850 | opt = np->opt; | 848 | opt = np->opt; |
| 851 | if (opt == NULL && | 849 | if (opt == NULL && |
| 852 | np->rxopt.bits.srcrt == 2 && | 850 | np->rxopt.bits.osrcrt == 2 && |
| 853 | treq->pktopts) { | 851 | treq->pktopts) { |
| 854 | struct sk_buff *pktopts = treq->pktopts; | 852 | struct sk_buff *pktopts = treq->pktopts; |
| 855 | struct inet6_skb_parm *rxopt = IP6CB(pktopts); | 853 | struct inet6_skb_parm *rxopt = IP6CB(pktopts); |
| @@ -888,7 +886,6 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, | |||
| 888 | } | 886 | } |
| 889 | 887 | ||
| 890 | done: | 888 | done: |
| 891 | dst_release(dst); | ||
| 892 | if (opt && opt != np->opt) | 889 | if (opt && opt != np->opt) |
| 893 | sock_kfree_s(sk, opt, opt->tot_len); | 890 | sock_kfree_s(sk, opt, opt->tot_len); |
| 894 | return err; | 891 | return err; |
| @@ -915,11 +912,10 @@ static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) | |||
| 915 | struct inet6_skb_parm *opt = IP6CB(skb); | 912 | struct inet6_skb_parm *opt = IP6CB(skb); |
| 916 | 913 | ||
| 917 | if (np->rxopt.all) { | 914 | if (np->rxopt.all) { |
| 918 | if ((opt->hop && np->rxopt.bits.hopopts) || | 915 | if ((opt->hop && (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || |
| 919 | ((IPV6_FLOWINFO_MASK&*(u32*)skb->nh.raw) && | 916 | ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) && np->rxopt.bits.rxflow) || |
| 920 | np->rxopt.bits.rxflow) || | 917 | (opt->srcrt && (np->rxopt.bits.srcrt || np->rxopt.bits.osrcrt)) || |
| 921 | (opt->srcrt && np->rxopt.bits.srcrt) || | 918 | ((opt->dst1 || opt->dst0) && (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) |
| 922 | ((opt->dst1 || opt->dst0) && np->rxopt.bits.dstopts)) | ||
| 923 | return 1; | 919 | return 1; |
| 924 | } | 920 | } |
| 925 | return 0; | 921 | return 0; |
| @@ -1001,10 +997,8 @@ static void tcp_v6_send_reset(struct sk_buff *skb) | |||
| 1001 | /* sk = NULL, but it is safe for now. RST socket required. */ | 997 | /* sk = NULL, but it is safe for now. RST socket required. */ |
| 1002 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { | 998 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { |
| 1003 | 999 | ||
| 1004 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) { | 1000 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) |
| 1005 | dst_release(buff->dst); | ||
| 1006 | return; | 1001 | return; |
| 1007 | } | ||
| 1008 | 1002 | ||
| 1009 | ip6_xmit(NULL, buff, &fl, NULL, 0); | 1003 | ip6_xmit(NULL, buff, &fl, NULL, 0); |
| 1010 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); | 1004 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); |
| @@ -1068,10 +1062,8 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 | |||
| 1068 | fl.fl_ip_sport = t1->source; | 1062 | fl.fl_ip_sport = t1->source; |
| 1069 | 1063 | ||
| 1070 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { | 1064 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { |
| 1071 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) { | 1065 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) |
| 1072 | dst_release(buff->dst); | ||
| 1073 | return; | 1066 | return; |
| 1074 | } | ||
| 1075 | ip6_xmit(NULL, buff, &fl, NULL, 0); | 1067 | ip6_xmit(NULL, buff, &fl, NULL, 0); |
| 1076 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); | 1068 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); |
| 1077 | return; | 1069 | return; |
| @@ -1190,8 +1182,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1190 | TCP_ECN_create_request(req, skb->h.th); | 1182 | TCP_ECN_create_request(req, skb->h.th); |
| 1191 | treq->pktopts = NULL; | 1183 | treq->pktopts = NULL; |
| 1192 | if (ipv6_opt_accepted(sk, skb) || | 1184 | if (ipv6_opt_accepted(sk, skb) || |
| 1193 | np->rxopt.bits.rxinfo || | 1185 | np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || |
| 1194 | np->rxopt.bits.rxhlim) { | 1186 | np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { |
| 1195 | atomic_inc(&skb->users); | 1187 | atomic_inc(&skb->users); |
| 1196 | treq->pktopts = skb; | 1188 | treq->pktopts = skb; |
| 1197 | } | 1189 | } |
| @@ -1288,7 +1280,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 1288 | if (sk_acceptq_is_full(sk)) | 1280 | if (sk_acceptq_is_full(sk)) |
| 1289 | goto out_overflow; | 1281 | goto out_overflow; |
| 1290 | 1282 | ||
| 1291 | if (np->rxopt.bits.srcrt == 2 && | 1283 | if (np->rxopt.bits.osrcrt == 2 && |
| 1292 | opt == NULL && treq->pktopts) { | 1284 | opt == NULL && treq->pktopts) { |
| 1293 | struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); | 1285 | struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); |
| 1294 | if (rxopt->srcrt) | 1286 | if (rxopt->srcrt) |
| @@ -1544,9 +1536,9 @@ ipv6_pktoptions: | |||
| 1544 | tp = tcp_sk(sk); | 1536 | tp = tcp_sk(sk); |
| 1545 | if (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt && | 1537 | if (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt && |
| 1546 | !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { | 1538 | !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { |
| 1547 | if (np->rxopt.bits.rxinfo) | 1539 | if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo) |
| 1548 | np->mcast_oif = inet6_iif(opt_skb); | 1540 | np->mcast_oif = inet6_iif(opt_skb); |
| 1549 | if (np->rxopt.bits.rxhlim) | 1541 | if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) |
| 1550 | np->mcast_hops = opt_skb->nh.ipv6h->hop_limit; | 1542 | np->mcast_hops = opt_skb->nh.ipv6h->hop_limit; |
| 1551 | if (ipv6_opt_accepted(sk, opt_skb)) { | 1543 | if (ipv6_opt_accepted(sk, opt_skb)) { |
| 1552 | skb_set_owner_r(opt_skb, sk); | 1544 | skb_set_owner_r(opt_skb, sk); |
| @@ -1734,7 +1726,6 @@ static int tcp_v6_rebuild_header(struct sock *sk) | |||
| 1734 | 1726 | ||
| 1735 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 1727 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { |
| 1736 | sk->sk_err_soft = -err; | 1728 | sk->sk_err_soft = -err; |
| 1737 | dst_release(dst); | ||
| 1738 | return err; | 1729 | return err; |
| 1739 | } | 1730 | } |
| 1740 | 1731 | ||
| @@ -1787,7 +1778,6 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok) | |||
| 1787 | 1778 | ||
| 1788 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 1779 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { |
| 1789 | sk->sk_route_caps = 0; | 1780 | sk->sk_route_caps = 0; |
| 1790 | dst_release(dst); | ||
| 1791 | return err; | 1781 | return err; |
| 1792 | } | 1782 | } |
| 1793 | 1783 | ||
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 390d750449ce..69b146843a20 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
| @@ -483,7 +483,7 @@ static int udpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp) | |||
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | if (ulen < skb->len) { | 485 | if (ulen < skb->len) { |
| 486 | if (__pskb_trim(skb, ulen)) | 486 | if (pskb_trim_rcsum(skb, ulen)) |
| 487 | goto discard; | 487 | goto discard; |
| 488 | saddr = &skb->nh.ipv6h->saddr; | 488 | saddr = &skb->nh.ipv6h->saddr; |
| 489 | daddr = &skb->nh.ipv6h->daddr; | 489 | daddr = &skb->nh.ipv6h->daddr; |
| @@ -637,6 +637,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 637 | int addr_len = msg->msg_namelen; | 637 | int addr_len = msg->msg_namelen; |
| 638 | int ulen = len; | 638 | int ulen = len; |
| 639 | int hlimit = -1; | 639 | int hlimit = -1; |
| 640 | int tclass = -1; | ||
| 640 | int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; | 641 | int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; |
| 641 | int err; | 642 | int err; |
| 642 | 643 | ||
| @@ -758,7 +759,7 @@ do_udp_sendmsg: | |||
| 758 | memset(opt, 0, sizeof(struct ipv6_txoptions)); | 759 | memset(opt, 0, sizeof(struct ipv6_txoptions)); |
| 759 | opt->tot_len = sizeof(*opt); | 760 | opt->tot_len = sizeof(*opt); |
| 760 | 761 | ||
| 761 | err = datagram_send_ctl(msg, fl, opt, &hlimit); | 762 | err = datagram_send_ctl(msg, fl, opt, &hlimit, &tclass); |
| 762 | if (err < 0) { | 763 | if (err < 0) { |
| 763 | fl6_sock_release(flowlabel); | 764 | fl6_sock_release(flowlabel); |
| 764 | return err; | 765 | return err; |
| @@ -773,8 +774,7 @@ do_udp_sendmsg: | |||
| 773 | } | 774 | } |
| 774 | if (opt == NULL) | 775 | if (opt == NULL) |
| 775 | opt = np->opt; | 776 | opt = np->opt; |
| 776 | if (flowlabel) | 777 | opt = fl6_merge_options(&opt_space, flowlabel, opt); |
| 777 | opt = fl6_merge_options(&opt_space, flowlabel, opt); | ||
| 778 | 778 | ||
| 779 | fl->proto = IPPROTO_UDP; | 779 | fl->proto = IPPROTO_UDP; |
| 780 | ipv6_addr_copy(&fl->fl6_dst, daddr); | 780 | ipv6_addr_copy(&fl->fl6_dst, daddr); |
| @@ -799,10 +799,8 @@ do_udp_sendmsg: | |||
| 799 | if (final_p) | 799 | if (final_p) |
| 800 | ipv6_addr_copy(&fl->fl6_dst, final_p); | 800 | ipv6_addr_copy(&fl->fl6_dst, final_p); |
| 801 | 801 | ||
| 802 | if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) { | 802 | if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) |
| 803 | dst_release(dst); | ||
| 804 | goto out; | 803 | goto out; |
| 805 | } | ||
| 806 | 804 | ||
| 807 | if (hlimit < 0) { | 805 | if (hlimit < 0) { |
| 808 | if (ipv6_addr_is_multicast(&fl->fl6_dst)) | 806 | if (ipv6_addr_is_multicast(&fl->fl6_dst)) |
| @@ -815,6 +813,12 @@ do_udp_sendmsg: | |||
| 815 | hlimit = ipv6_get_hoplimit(dst->dev); | 813 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 816 | } | 814 | } |
| 817 | 815 | ||
| 816 | if (tclass < 0) { | ||
| 817 | tclass = np->tclass; | ||
| 818 | if (tclass < 0) | ||
| 819 | tclass = 0; | ||
| 820 | } | ||
| 821 | |||
| 818 | if (msg->msg_flags&MSG_CONFIRM) | 822 | if (msg->msg_flags&MSG_CONFIRM) |
| 819 | goto do_confirm; | 823 | goto do_confirm; |
| 820 | back_from_confirm: | 824 | back_from_confirm: |
| @@ -834,9 +838,10 @@ back_from_confirm: | |||
| 834 | 838 | ||
| 835 | do_append_data: | 839 | do_append_data: |
| 836 | up->len += ulen; | 840 | up->len += ulen; |
| 837 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, sizeof(struct udphdr), | 841 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, |
| 838 | hlimit, opt, fl, (struct rt6_info*)dst, | 842 | sizeof(struct udphdr), hlimit, tclass, opt, fl, |
| 839 | corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); | 843 | (struct rt6_info*)dst, |
| 844 | corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); | ||
| 840 | if (err) | 845 | if (err) |
| 841 | udp_v6_flush_pending_frames(sk); | 846 | udp_v6_flush_pending_frames(sk); |
| 842 | else if (!corkreq) | 847 | else if (!corkreq) |
