diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-01-16 16:21:04 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-01-16 16:21:04 -0500 |
commit | f652f6c5b7cfdf139f4155d78f397e99ae1c4acc (patch) | |
tree | 71c6344688bf56ea6aaf18c586ab69ff4f077ade /net/ipv6 | |
parent | 140e3008e7fe1526cbb12f8f07dbc273ac713b75 (diff) | |
parent | c66ac9db8d4ad9994a02b3e933ea2ccc643e1fe5 (diff) |
Merge branch 'master' of /pub/scm/linux/kernel/git/jejb/scsi-post-merge-2.6 into for-linus
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/addrconf.c | 119 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 4 | ||||
-rw-r--r-- | net/ipv6/ah6.c | 8 | ||||
-rw-r--r-- | net/ipv6/esp6.c | 32 | ||||
-rw-r--r-- | net/ipv6/inet6_connection_sock.c | 56 | ||||
-rw-r--r-- | net/ipv6/ip6_output.c | 12 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 2 | ||||
-rw-r--r-- | net/ipv6/ip6mr.c | 4 | ||||
-rw-r--r-- | net/ipv6/mcast.c | 77 | ||||
-rw-r--r-- | net/ipv6/ndisc.c | 29 | ||||
-rw-r--r-- | net/ipv6/netfilter.c | 6 | ||||
-rw-r--r-- | net/ipv6/netfilter/Makefile | 4 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6_tables.c | 45 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_REJECT.c | 2 | ||||
-rw-r--r-- | net/ipv6/reassembly.c | 36 | ||||
-rw-r--r-- | net/ipv6/route.c | 163 | ||||
-rw-r--r-- | net/ipv6/sit.c | 14 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 151 | ||||
-rw-r--r-- | net/ipv6/udp.c | 11 | ||||
-rw-r--r-- | net/ipv6/udplite.c | 1 | ||||
-rw-r--r-- | net/ipv6/xfrm6_mode_tunnel.c | 3 | ||||
-rw-r--r-- | net/ipv6/xfrm6_output.c | 16 |
22 files changed, 487 insertions, 308 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 93b7a933a775..5b189c97c2fc 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -2669,8 +2669,9 @@ static int addrconf_ifdown(struct net_device *dev, int how) | |||
2669 | 2669 | ||
2670 | ASSERT_RTNL(); | 2670 | ASSERT_RTNL(); |
2671 | 2671 | ||
2672 | rt6_ifdown(net, dev); | 2672 | /* Flush routes if device is being removed or it is not loopback */ |
2673 | neigh_ifdown(&nd_tbl, dev); | 2673 | if (how || !(dev->flags & IFF_LOOPBACK)) |
2674 | rt6_ifdown(net, dev); | ||
2674 | 2675 | ||
2675 | idev = __in6_dev_get(dev); | 2676 | idev = __in6_dev_get(dev); |
2676 | if (idev == NULL) | 2677 | if (idev == NULL) |
@@ -3836,6 +3837,15 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, | |||
3836 | array[DEVCONF_FORCE_TLLAO] = cnf->force_tllao; | 3837 | array[DEVCONF_FORCE_TLLAO] = cnf->force_tllao; |
3837 | } | 3838 | } |
3838 | 3839 | ||
3840 | static inline size_t inet6_ifla6_size(void) | ||
3841 | { | ||
3842 | return nla_total_size(4) /* IFLA_INET6_FLAGS */ | ||
3843 | + nla_total_size(sizeof(struct ifla_cacheinfo)) | ||
3844 | + nla_total_size(DEVCONF_MAX * 4) /* IFLA_INET6_CONF */ | ||
3845 | + nla_total_size(IPSTATS_MIB_MAX * 8) /* IFLA_INET6_STATS */ | ||
3846 | + nla_total_size(ICMP6_MIB_MAX * 8); /* IFLA_INET6_ICMP6STATS */ | ||
3847 | } | ||
3848 | |||
3839 | static inline size_t inet6_if_nlmsg_size(void) | 3849 | static inline size_t inet6_if_nlmsg_size(void) |
3840 | { | 3850 | { |
3841 | return NLMSG_ALIGN(sizeof(struct ifinfomsg)) | 3851 | return NLMSG_ALIGN(sizeof(struct ifinfomsg)) |
@@ -3843,13 +3853,7 @@ static inline size_t inet6_if_nlmsg_size(void) | |||
3843 | + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */ | 3853 | + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */ |
3844 | + nla_total_size(4) /* IFLA_MTU */ | 3854 | + nla_total_size(4) /* IFLA_MTU */ |
3845 | + nla_total_size(4) /* IFLA_LINK */ | 3855 | + nla_total_size(4) /* IFLA_LINK */ |
3846 | + nla_total_size( /* IFLA_PROTINFO */ | 3856 | + nla_total_size(inet6_ifla6_size()); /* IFLA_PROTINFO */ |
3847 | nla_total_size(4) /* IFLA_INET6_FLAGS */ | ||
3848 | + nla_total_size(sizeof(struct ifla_cacheinfo)) | ||
3849 | + nla_total_size(DEVCONF_MAX * 4) /* IFLA_INET6_CONF */ | ||
3850 | + nla_total_size(IPSTATS_MIB_MAX * 8) /* IFLA_INET6_STATS */ | ||
3851 | + nla_total_size(ICMP6_MIB_MAX * 8) /* IFLA_INET6_ICMP6STATS */ | ||
3852 | ); | ||
3853 | } | 3857 | } |
3854 | 3858 | ||
3855 | static inline void __snmp6_fill_stats(u64 *stats, void __percpu **mib, | 3859 | static inline void __snmp6_fill_stats(u64 *stats, void __percpu **mib, |
@@ -3896,15 +3900,70 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype, | |||
3896 | } | 3900 | } |
3897 | } | 3901 | } |
3898 | 3902 | ||
3903 | static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev) | ||
3904 | { | ||
3905 | struct nlattr *nla; | ||
3906 | struct ifla_cacheinfo ci; | ||
3907 | |||
3908 | NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags); | ||
3909 | |||
3910 | ci.max_reasm_len = IPV6_MAXPLEN; | ||
3911 | ci.tstamp = cstamp_delta(idev->tstamp); | ||
3912 | ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time); | ||
3913 | ci.retrans_time = jiffies_to_msecs(idev->nd_parms->retrans_time); | ||
3914 | NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci); | ||
3915 | |||
3916 | nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); | ||
3917 | if (nla == NULL) | ||
3918 | goto nla_put_failure; | ||
3919 | ipv6_store_devconf(&idev->cnf, nla_data(nla), nla_len(nla)); | ||
3920 | |||
3921 | /* XXX - MC not implemented */ | ||
3922 | |||
3923 | nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64)); | ||
3924 | if (nla == NULL) | ||
3925 | goto nla_put_failure; | ||
3926 | snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla)); | ||
3927 | |||
3928 | nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64)); | ||
3929 | if (nla == NULL) | ||
3930 | goto nla_put_failure; | ||
3931 | snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla)); | ||
3932 | |||
3933 | return 0; | ||
3934 | |||
3935 | nla_put_failure: | ||
3936 | return -EMSGSIZE; | ||
3937 | } | ||
3938 | |||
3939 | static size_t inet6_get_link_af_size(const struct net_device *dev) | ||
3940 | { | ||
3941 | if (!__in6_dev_get(dev)) | ||
3942 | return 0; | ||
3943 | |||
3944 | return inet6_ifla6_size(); | ||
3945 | } | ||
3946 | |||
3947 | static int inet6_fill_link_af(struct sk_buff *skb, const struct net_device *dev) | ||
3948 | { | ||
3949 | struct inet6_dev *idev = __in6_dev_get(dev); | ||
3950 | |||
3951 | if (!idev) | ||
3952 | return -ENODATA; | ||
3953 | |||
3954 | if (inet6_fill_ifla6_attrs(skb, idev) < 0) | ||
3955 | return -EMSGSIZE; | ||
3956 | |||
3957 | return 0; | ||
3958 | } | ||
3959 | |||
3899 | static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, | 3960 | static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, |
3900 | u32 pid, u32 seq, int event, unsigned int flags) | 3961 | u32 pid, u32 seq, int event, unsigned int flags) |
3901 | { | 3962 | { |
3902 | struct net_device *dev = idev->dev; | 3963 | struct net_device *dev = idev->dev; |
3903 | struct nlattr *nla; | ||
3904 | struct ifinfomsg *hdr; | 3964 | struct ifinfomsg *hdr; |
3905 | struct nlmsghdr *nlh; | 3965 | struct nlmsghdr *nlh; |
3906 | void *protoinfo; | 3966 | void *protoinfo; |
3907 | struct ifla_cacheinfo ci; | ||
3908 | 3967 | ||
3909 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags); | 3968 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags); |
3910 | if (nlh == NULL) | 3969 | if (nlh == NULL) |
@@ -3931,30 +3990,8 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, | |||
3931 | if (protoinfo == NULL) | 3990 | if (protoinfo == NULL) |
3932 | goto nla_put_failure; | 3991 | goto nla_put_failure; |
3933 | 3992 | ||
3934 | NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags); | 3993 | if (inet6_fill_ifla6_attrs(skb, idev) < 0) |
3935 | |||
3936 | ci.max_reasm_len = IPV6_MAXPLEN; | ||
3937 | ci.tstamp = cstamp_delta(idev->tstamp); | ||
3938 | ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time); | ||
3939 | ci.retrans_time = jiffies_to_msecs(idev->nd_parms->retrans_time); | ||
3940 | NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci); | ||
3941 | |||
3942 | nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); | ||
3943 | if (nla == NULL) | ||
3944 | goto nla_put_failure; | ||
3945 | ipv6_store_devconf(&idev->cnf, nla_data(nla), nla_len(nla)); | ||
3946 | |||
3947 | /* XXX - MC not implemented */ | ||
3948 | |||
3949 | nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64)); | ||
3950 | if (nla == NULL) | ||
3951 | goto nla_put_failure; | ||
3952 | snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla)); | ||
3953 | |||
3954 | nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64)); | ||
3955 | if (nla == NULL) | ||
3956 | goto nla_put_failure; | 3994 | goto nla_put_failure; |
3957 | snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla)); | ||
3958 | 3995 | ||
3959 | nla_nest_end(skb, protoinfo); | 3996 | nla_nest_end(skb, protoinfo); |
3960 | return nlmsg_end(skb, nlh); | 3997 | return nlmsg_end(skb, nlh); |
@@ -4625,6 +4662,12 @@ int unregister_inet6addr_notifier(struct notifier_block *nb) | |||
4625 | } | 4662 | } |
4626 | EXPORT_SYMBOL(unregister_inet6addr_notifier); | 4663 | EXPORT_SYMBOL(unregister_inet6addr_notifier); |
4627 | 4664 | ||
4665 | static struct rtnl_af_ops inet6_ops = { | ||
4666 | .family = AF_INET6, | ||
4667 | .fill_link_af = inet6_fill_link_af, | ||
4668 | .get_link_af_size = inet6_get_link_af_size, | ||
4669 | }; | ||
4670 | |||
4628 | /* | 4671 | /* |
4629 | * Init / cleanup code | 4672 | * Init / cleanup code |
4630 | */ | 4673 | */ |
@@ -4676,6 +4719,10 @@ int __init addrconf_init(void) | |||
4676 | 4719 | ||
4677 | addrconf_verify(0); | 4720 | addrconf_verify(0); |
4678 | 4721 | ||
4722 | err = rtnl_af_register(&inet6_ops); | ||
4723 | if (err < 0) | ||
4724 | goto errout_af; | ||
4725 | |||
4679 | err = __rtnl_register(PF_INET6, RTM_GETLINK, NULL, inet6_dump_ifinfo); | 4726 | err = __rtnl_register(PF_INET6, RTM_GETLINK, NULL, inet6_dump_ifinfo); |
4680 | if (err < 0) | 4727 | if (err < 0) |
4681 | goto errout; | 4728 | goto errout; |
@@ -4691,6 +4738,8 @@ int __init addrconf_init(void) | |||
4691 | 4738 | ||
4692 | return 0; | 4739 | return 0; |
4693 | errout: | 4740 | errout: |
4741 | rtnl_af_unregister(&inet6_ops); | ||
4742 | errout_af: | ||
4694 | unregister_netdevice_notifier(&ipv6_dev_notf); | 4743 | unregister_netdevice_notifier(&ipv6_dev_notf); |
4695 | errlo: | 4744 | errlo: |
4696 | unregister_pernet_subsys(&addrconf_ops); | 4745 | unregister_pernet_subsys(&addrconf_ops); |
@@ -4711,6 +4760,8 @@ void addrconf_cleanup(void) | |||
4711 | 4760 | ||
4712 | rtnl_lock(); | 4761 | rtnl_lock(); |
4713 | 4762 | ||
4763 | __rtnl_af_unregister(&inet6_ops); | ||
4764 | |||
4714 | /* clean dev list */ | 4765 | /* clean dev list */ |
4715 | for_each_netdev(&init_net, dev) { | 4766 | for_each_netdev(&init_net, dev) { |
4716 | if (__in6_dev_get(dev) == NULL) | 4767 | if (__in6_dev_get(dev) == NULL) |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 54e8e42f7a88..978e80e2c4a8 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -300,7 +300,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
300 | goto out; | 300 | goto out; |
301 | } | 301 | } |
302 | 302 | ||
303 | /* Reproduce AF_INET checks to make the bindings consitant */ | 303 | /* Reproduce AF_INET checks to make the bindings consistent */ |
304 | v4addr = addr->sin6_addr.s6_addr32[3]; | 304 | v4addr = addr->sin6_addr.s6_addr32[3]; |
305 | chk_addr_ret = inet_addr_type(net, v4addr); | 305 | chk_addr_ret = inet_addr_type(net, v4addr); |
306 | if (!sysctl_ip_nonlocal_bind && | 306 | if (!sysctl_ip_nonlocal_bind && |
@@ -810,7 +810,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features) | |||
810 | } | 810 | } |
811 | rcu_read_unlock(); | 811 | rcu_read_unlock(); |
812 | 812 | ||
813 | if (unlikely(IS_ERR(segs))) | 813 | if (IS_ERR(segs)) |
814 | goto out; | 814 | goto out; |
815 | 815 | ||
816 | for (skb = segs; skb; skb = skb->next) { | 816 | for (skb = segs; skb; skb = skb->next) { |
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index ee82d4ef26ce..1aba54ae53c4 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c | |||
@@ -538,14 +538,16 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
538 | if (!pskb_may_pull(skb, ah_hlen)) | 538 | if (!pskb_may_pull(skb, ah_hlen)) |
539 | goto out; | 539 | goto out; |
540 | 540 | ||
541 | ip6h = ipv6_hdr(skb); | ||
542 | |||
543 | skb_push(skb, hdr_len); | ||
544 | 541 | ||
545 | if ((err = skb_cow_data(skb, 0, &trailer)) < 0) | 542 | if ((err = skb_cow_data(skb, 0, &trailer)) < 0) |
546 | goto out; | 543 | goto out; |
547 | nfrags = err; | 544 | nfrags = err; |
548 | 545 | ||
546 | ah = (struct ip_auth_hdr *)skb->data; | ||
547 | ip6h = ipv6_hdr(skb); | ||
548 | |||
549 | skb_push(skb, hdr_len); | ||
550 | |||
549 | work_iph = ah_alloc_tmp(ahash, nfrags, hdr_len + ahp->icv_trunc_len); | 551 | work_iph = ah_alloc_tmp(ahash, nfrags, hdr_len + ahp->icv_trunc_len); |
550 | if (!work_iph) | 552 | if (!work_iph) |
551 | goto out; | 553 | goto out; |
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index ee9b93bdd6a2..1b5c9825743b 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
@@ -49,6 +49,8 @@ struct esp_skb_cb { | |||
49 | 49 | ||
50 | #define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0])) | 50 | #define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0])) |
51 | 51 | ||
52 | static u32 esp6_get_mtu(struct xfrm_state *x, int mtu); | ||
53 | |||
52 | /* | 54 | /* |
53 | * Allocate an AEAD request structure with extra space for SG and IV. | 55 | * Allocate an AEAD request structure with extra space for SG and IV. |
54 | * | 56 | * |
@@ -140,6 +142,8 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
140 | int blksize; | 142 | int blksize; |
141 | int clen; | 143 | int clen; |
142 | int alen; | 144 | int alen; |
145 | int plen; | ||
146 | int tfclen; | ||
143 | int nfrags; | 147 | int nfrags; |
144 | u8 *iv; | 148 | u8 *iv; |
145 | u8 *tail; | 149 | u8 *tail; |
@@ -148,18 +152,26 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
148 | /* skb is pure payload to encrypt */ | 152 | /* skb is pure payload to encrypt */ |
149 | err = -ENOMEM; | 153 | err = -ENOMEM; |
150 | 154 | ||
151 | /* Round to block size */ | ||
152 | clen = skb->len; | ||
153 | |||
154 | aead = esp->aead; | 155 | aead = esp->aead; |
155 | alen = crypto_aead_authsize(aead); | 156 | alen = crypto_aead_authsize(aead); |
156 | 157 | ||
158 | tfclen = 0; | ||
159 | if (x->tfcpad) { | ||
160 | struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); | ||
161 | u32 padto; | ||
162 | |||
163 | padto = min(x->tfcpad, esp6_get_mtu(x, dst->child_mtu_cached)); | ||
164 | if (skb->len < padto) | ||
165 | tfclen = padto - skb->len; | ||
166 | } | ||
157 | blksize = ALIGN(crypto_aead_blocksize(aead), 4); | 167 | blksize = ALIGN(crypto_aead_blocksize(aead), 4); |
158 | clen = ALIGN(clen + 2, blksize); | 168 | clen = ALIGN(skb->len + 2 + tfclen, blksize); |
159 | if (esp->padlen) | 169 | if (esp->padlen) |
160 | clen = ALIGN(clen, esp->padlen); | 170 | clen = ALIGN(clen, esp->padlen); |
171 | plen = clen - skb->len - tfclen; | ||
161 | 172 | ||
162 | if ((err = skb_cow_data(skb, clen - skb->len + alen, &trailer)) < 0) | 173 | err = skb_cow_data(skb, tfclen + plen + alen, &trailer); |
174 | if (err < 0) | ||
163 | goto error; | 175 | goto error; |
164 | nfrags = err; | 176 | nfrags = err; |
165 | 177 | ||
@@ -174,13 +186,17 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
174 | 186 | ||
175 | /* Fill padding... */ | 187 | /* Fill padding... */ |
176 | tail = skb_tail_pointer(trailer); | 188 | tail = skb_tail_pointer(trailer); |
189 | if (tfclen) { | ||
190 | memset(tail, 0, tfclen); | ||
191 | tail += tfclen; | ||
192 | } | ||
177 | do { | 193 | do { |
178 | int i; | 194 | int i; |
179 | for (i=0; i<clen-skb->len - 2; i++) | 195 | for (i = 0; i < plen - 2; i++) |
180 | tail[i] = i + 1; | 196 | tail[i] = i + 1; |
181 | } while (0); | 197 | } while (0); |
182 | tail[clen-skb->len - 2] = (clen - skb->len) - 2; | 198 | tail[plen - 2] = plen - 2; |
183 | tail[clen - skb->len - 1] = *skb_mac_header(skb); | 199 | tail[plen - 1] = *skb_mac_header(skb); |
184 | pskb_put(skb, trailer, clen - skb->len + alen); | 200 | pskb_put(skb, trailer, clen - skb->len + alen); |
185 | 201 | ||
186 | skb_push(skb, -skb_network_offset(skb)); | 202 | skb_push(skb, -skb_network_offset(skb)); |
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c index 8a1628023bd1..d144e629d2b4 100644 --- a/net/ipv6/inet6_connection_sock.c +++ b/net/ipv6/inet6_connection_sock.c | |||
@@ -44,7 +44,7 @@ int inet6_csk_bind_conflict(const struct sock *sk, | |||
44 | !sk2->sk_bound_dev_if || | 44 | !sk2->sk_bound_dev_if || |
45 | sk->sk_bound_dev_if == sk2->sk_bound_dev_if) && | 45 | sk->sk_bound_dev_if == sk2->sk_bound_dev_if) && |
46 | (!sk->sk_reuse || !sk2->sk_reuse || | 46 | (!sk->sk_reuse || !sk2->sk_reuse || |
47 | sk2->sk_state == TCP_LISTEN) && | 47 | ((1 << sk2->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))) && |
48 | ipv6_rcv_saddr_equal(sk, sk2)) | 48 | ipv6_rcv_saddr_equal(sk, sk2)) |
49 | break; | 49 | break; |
50 | } | 50 | } |
@@ -54,24 +54,54 @@ int inet6_csk_bind_conflict(const struct sock *sk, | |||
54 | 54 | ||
55 | EXPORT_SYMBOL_GPL(inet6_csk_bind_conflict); | 55 | EXPORT_SYMBOL_GPL(inet6_csk_bind_conflict); |
56 | 56 | ||
57 | struct dst_entry *inet6_csk_route_req(struct sock *sk, | ||
58 | const struct request_sock *req) | ||
59 | { | ||
60 | struct inet6_request_sock *treq = inet6_rsk(req); | ||
61 | struct ipv6_pinfo *np = inet6_sk(sk); | ||
62 | struct in6_addr *final_p, final; | ||
63 | struct dst_entry *dst; | ||
64 | struct flowi fl; | ||
65 | |||
66 | memset(&fl, 0, sizeof(fl)); | ||
67 | fl.proto = IPPROTO_TCP; | ||
68 | ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); | ||
69 | final_p = fl6_update_dst(&fl, np->opt, &final); | ||
70 | ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr); | ||
71 | fl.oif = sk->sk_bound_dev_if; | ||
72 | fl.mark = sk->sk_mark; | ||
73 | fl.fl_ip_dport = inet_rsk(req)->rmt_port; | ||
74 | fl.fl_ip_sport = inet_rsk(req)->loc_port; | ||
75 | security_req_classify_flow(req, &fl); | ||
76 | |||
77 | if (ip6_dst_lookup(sk, &dst, &fl)) | ||
78 | return NULL; | ||
79 | |||
80 | if (final_p) | ||
81 | ipv6_addr_copy(&fl.fl6_dst, final_p); | ||
82 | |||
83 | if ((xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0) | ||
84 | return NULL; | ||
85 | |||
86 | return dst; | ||
87 | } | ||
88 | |||
57 | /* | 89 | /* |
58 | * request_sock (formerly open request) hash tables. | 90 | * request_sock (formerly open request) hash tables. |
59 | */ | 91 | */ |
60 | static u32 inet6_synq_hash(const struct in6_addr *raddr, const __be16 rport, | 92 | static u32 inet6_synq_hash(const struct in6_addr *raddr, const __be16 rport, |
61 | const u32 rnd, const u16 synq_hsize) | 93 | const u32 rnd, const u16 synq_hsize) |
62 | { | 94 | { |
63 | u32 a = (__force u32)raddr->s6_addr32[0]; | 95 | u32 c; |
64 | u32 b = (__force u32)raddr->s6_addr32[1]; | 96 | |
65 | u32 c = (__force u32)raddr->s6_addr32[2]; | 97 | c = jhash_3words((__force u32)raddr->s6_addr32[0], |
66 | 98 | (__force u32)raddr->s6_addr32[1], | |
67 | a += JHASH_GOLDEN_RATIO; | 99 | (__force u32)raddr->s6_addr32[2], |
68 | b += JHASH_GOLDEN_RATIO; | 100 | rnd); |
69 | c += rnd; | 101 | |
70 | __jhash_mix(a, b, c); | 102 | c = jhash_2words((__force u32)raddr->s6_addr32[3], |
71 | 103 | (__force u32)rport, | |
72 | a += (__force u32)raddr->s6_addr32[3]; | 104 | c); |
73 | b += (__force u32)rport; | ||
74 | __jhash_mix(a, b, c); | ||
75 | 105 | ||
76 | return c & (synq_hsize - 1); | 106 | return c & (synq_hsize - 1); |
77 | } | 107 | } |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 99157b4cd56e..94b5bf132b2e 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <net/checksum.h> | 56 | #include <net/checksum.h> |
57 | #include <linux/mroute6.h> | 57 | #include <linux/mroute6.h> |
58 | 58 | ||
59 | static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); | 59 | int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); |
60 | 60 | ||
61 | int __ip6_local_out(struct sk_buff *skb) | 61 | int __ip6_local_out(struct sk_buff *skb) |
62 | { | 62 | { |
@@ -145,14 +145,6 @@ static int ip6_finish_output2(struct sk_buff *skb) | |||
145 | return -EINVAL; | 145 | return -EINVAL; |
146 | } | 146 | } |
147 | 147 | ||
148 | static inline int ip6_skb_dst_mtu(struct sk_buff *skb) | ||
149 | { | ||
150 | struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL; | ||
151 | |||
152 | return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ? | ||
153 | skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb)); | ||
154 | } | ||
155 | |||
156 | static int ip6_finish_output(struct sk_buff *skb) | 148 | static int ip6_finish_output(struct sk_buff *skb) |
157 | { | 149 | { |
158 | if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || | 150 | if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || |
@@ -601,7 +593,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | |||
601 | return offset; | 593 | return offset; |
602 | } | 594 | } |
603 | 595 | ||
604 | static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | 596 | int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) |
605 | { | 597 | { |
606 | struct sk_buff *frag; | 598 | struct sk_buff *frag; |
607 | struct rt6_info *rt = (struct rt6_info*)skb_dst(skb); | 599 | struct rt6_info *rt = (struct rt6_info*)skb_dst(skb); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 70e891a20fb9..4f4483e697bd 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -58,8 +58,6 @@ MODULE_AUTHOR("Ville Nuorvala"); | |||
58 | MODULE_DESCRIPTION("IPv6 tunneling device"); | 58 | MODULE_DESCRIPTION("IPv6 tunneling device"); |
59 | MODULE_LICENSE("GPL"); | 59 | MODULE_LICENSE("GPL"); |
60 | 60 | ||
61 | #define IPV6_TLV_TEL_DST_SIZE 8 | ||
62 | |||
63 | #ifdef IP6_TNL_DEBUG | 61 | #ifdef IP6_TNL_DEBUG |
64 | #define IP6_TNL_TRACE(x...) printk(KERN_DEBUG "%s:" x "\n", __func__) | 62 | #define IP6_TNL_TRACE(x...) printk(KERN_DEBUG "%s:" x "\n", __func__) |
65 | #else | 63 | #else |
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 6f32ffce7022..9fab274019c0 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c | |||
@@ -1843,9 +1843,7 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, | |||
1843 | 1843 | ||
1844 | fl = (struct flowi) { | 1844 | fl = (struct flowi) { |
1845 | .oif = vif->link, | 1845 | .oif = vif->link, |
1846 | .nl_u = { .ip6_u = | 1846 | .fl6_dst = ipv6h->daddr, |
1847 | { .daddr = ipv6h->daddr, } | ||
1848 | } | ||
1849 | }; | 1847 | }; |
1850 | 1848 | ||
1851 | dst = ip6_route_output(net, NULL, &fl); | 1849 | dst = ip6_route_output(net, NULL, &fl); |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index d1444b95ad7e..49f986d626a0 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -82,7 +82,7 @@ static void *__mld2_query_bugs[] __attribute__((__unused__)) = { | |||
82 | static struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT; | 82 | static struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT; |
83 | 83 | ||
84 | /* Big mc list lock for all the sockets */ | 84 | /* Big mc list lock for all the sockets */ |
85 | static DEFINE_RWLOCK(ipv6_sk_mc_lock); | 85 | static DEFINE_SPINLOCK(ipv6_sk_mc_lock); |
86 | 86 | ||
87 | static void igmp6_join_group(struct ifmcaddr6 *ma); | 87 | static void igmp6_join_group(struct ifmcaddr6 *ma); |
88 | static void igmp6_leave_group(struct ifmcaddr6 *ma); | 88 | static void igmp6_leave_group(struct ifmcaddr6 *ma); |
@@ -123,6 +123,11 @@ int sysctl_mld_max_msf __read_mostly = IPV6_MLD_MAX_MSF; | |||
123 | * socket join on multicast group | 123 | * socket join on multicast group |
124 | */ | 124 | */ |
125 | 125 | ||
126 | #define for_each_pmc_rcu(np, pmc) \ | ||
127 | for (pmc = rcu_dereference(np->ipv6_mc_list); \ | ||
128 | pmc != NULL; \ | ||
129 | pmc = rcu_dereference(pmc->next)) | ||
130 | |||
126 | int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr) | 131 | int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr) |
127 | { | 132 | { |
128 | struct net_device *dev = NULL; | 133 | struct net_device *dev = NULL; |
@@ -134,15 +139,15 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr) | |||
134 | if (!ipv6_addr_is_multicast(addr)) | 139 | if (!ipv6_addr_is_multicast(addr)) |
135 | return -EINVAL; | 140 | return -EINVAL; |
136 | 141 | ||
137 | read_lock_bh(&ipv6_sk_mc_lock); | 142 | rcu_read_lock(); |
138 | for (mc_lst=np->ipv6_mc_list; mc_lst; mc_lst=mc_lst->next) { | 143 | for_each_pmc_rcu(np, mc_lst) { |
139 | if ((ifindex == 0 || mc_lst->ifindex == ifindex) && | 144 | if ((ifindex == 0 || mc_lst->ifindex == ifindex) && |
140 | ipv6_addr_equal(&mc_lst->addr, addr)) { | 145 | ipv6_addr_equal(&mc_lst->addr, addr)) { |
141 | read_unlock_bh(&ipv6_sk_mc_lock); | 146 | rcu_read_unlock(); |
142 | return -EADDRINUSE; | 147 | return -EADDRINUSE; |
143 | } | 148 | } |
144 | } | 149 | } |
145 | read_unlock_bh(&ipv6_sk_mc_lock); | 150 | rcu_read_unlock(); |
146 | 151 | ||
147 | mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL); | 152 | mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL); |
148 | 153 | ||
@@ -186,33 +191,41 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr) | |||
186 | return err; | 191 | return err; |
187 | } | 192 | } |
188 | 193 | ||
189 | write_lock_bh(&ipv6_sk_mc_lock); | 194 | spin_lock(&ipv6_sk_mc_lock); |
190 | mc_lst->next = np->ipv6_mc_list; | 195 | mc_lst->next = np->ipv6_mc_list; |
191 | np->ipv6_mc_list = mc_lst; | 196 | rcu_assign_pointer(np->ipv6_mc_list, mc_lst); |
192 | write_unlock_bh(&ipv6_sk_mc_lock); | 197 | spin_unlock(&ipv6_sk_mc_lock); |
193 | 198 | ||
194 | rcu_read_unlock(); | 199 | rcu_read_unlock(); |
195 | 200 | ||
196 | return 0; | 201 | return 0; |
197 | } | 202 | } |
198 | 203 | ||
204 | static void ipv6_mc_socklist_reclaim(struct rcu_head *head) | ||
205 | { | ||
206 | kfree(container_of(head, struct ipv6_mc_socklist, rcu)); | ||
207 | } | ||
199 | /* | 208 | /* |
200 | * socket leave on multicast group | 209 | * socket leave on multicast group |
201 | */ | 210 | */ |
202 | int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr) | 211 | int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr) |
203 | { | 212 | { |
204 | struct ipv6_pinfo *np = inet6_sk(sk); | 213 | struct ipv6_pinfo *np = inet6_sk(sk); |
205 | struct ipv6_mc_socklist *mc_lst, **lnk; | 214 | struct ipv6_mc_socklist *mc_lst; |
215 | struct ipv6_mc_socklist __rcu **lnk; | ||
206 | struct net *net = sock_net(sk); | 216 | struct net *net = sock_net(sk); |
207 | 217 | ||
208 | write_lock_bh(&ipv6_sk_mc_lock); | 218 | spin_lock(&ipv6_sk_mc_lock); |
209 | for (lnk = &np->ipv6_mc_list; (mc_lst = *lnk) !=NULL ; lnk = &mc_lst->next) { | 219 | for (lnk = &np->ipv6_mc_list; |
220 | (mc_lst = rcu_dereference_protected(*lnk, | ||
221 | lockdep_is_held(&ipv6_sk_mc_lock))) !=NULL ; | ||
222 | lnk = &mc_lst->next) { | ||
210 | if ((ifindex == 0 || mc_lst->ifindex == ifindex) && | 223 | if ((ifindex == 0 || mc_lst->ifindex == ifindex) && |
211 | ipv6_addr_equal(&mc_lst->addr, addr)) { | 224 | ipv6_addr_equal(&mc_lst->addr, addr)) { |
212 | struct net_device *dev; | 225 | struct net_device *dev; |
213 | 226 | ||
214 | *lnk = mc_lst->next; | 227 | *lnk = mc_lst->next; |
215 | write_unlock_bh(&ipv6_sk_mc_lock); | 228 | spin_unlock(&ipv6_sk_mc_lock); |
216 | 229 | ||
217 | rcu_read_lock(); | 230 | rcu_read_lock(); |
218 | dev = dev_get_by_index_rcu(net, mc_lst->ifindex); | 231 | dev = dev_get_by_index_rcu(net, mc_lst->ifindex); |
@@ -225,11 +238,12 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr) | |||
225 | } else | 238 | } else |
226 | (void) ip6_mc_leave_src(sk, mc_lst, NULL); | 239 | (void) ip6_mc_leave_src(sk, mc_lst, NULL); |
227 | rcu_read_unlock(); | 240 | rcu_read_unlock(); |
228 | sock_kfree_s(sk, mc_lst, sizeof(*mc_lst)); | 241 | atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc); |
242 | call_rcu(&mc_lst->rcu, ipv6_mc_socklist_reclaim); | ||
229 | return 0; | 243 | return 0; |
230 | } | 244 | } |
231 | } | 245 | } |
232 | write_unlock_bh(&ipv6_sk_mc_lock); | 246 | spin_unlock(&ipv6_sk_mc_lock); |
233 | 247 | ||
234 | return -EADDRNOTAVAIL; | 248 | return -EADDRNOTAVAIL; |
235 | } | 249 | } |
@@ -257,7 +271,7 @@ static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net, | |||
257 | return NULL; | 271 | return NULL; |
258 | idev = __in6_dev_get(dev); | 272 | idev = __in6_dev_get(dev); |
259 | if (!idev) | 273 | if (!idev) |
260 | return NULL;; | 274 | return NULL; |
261 | read_lock_bh(&idev->lock); | 275 | read_lock_bh(&idev->lock); |
262 | if (idev->dead) { | 276 | if (idev->dead) { |
263 | read_unlock_bh(&idev->lock); | 277 | read_unlock_bh(&idev->lock); |
@@ -272,12 +286,13 @@ void ipv6_sock_mc_close(struct sock *sk) | |||
272 | struct ipv6_mc_socklist *mc_lst; | 286 | struct ipv6_mc_socklist *mc_lst; |
273 | struct net *net = sock_net(sk); | 287 | struct net *net = sock_net(sk); |
274 | 288 | ||
275 | write_lock_bh(&ipv6_sk_mc_lock); | 289 | spin_lock(&ipv6_sk_mc_lock); |
276 | while ((mc_lst = np->ipv6_mc_list) != NULL) { | 290 | while ((mc_lst = rcu_dereference_protected(np->ipv6_mc_list, |
291 | lockdep_is_held(&ipv6_sk_mc_lock))) != NULL) { | ||
277 | struct net_device *dev; | 292 | struct net_device *dev; |
278 | 293 | ||
279 | np->ipv6_mc_list = mc_lst->next; | 294 | np->ipv6_mc_list = mc_lst->next; |
280 | write_unlock_bh(&ipv6_sk_mc_lock); | 295 | spin_unlock(&ipv6_sk_mc_lock); |
281 | 296 | ||
282 | rcu_read_lock(); | 297 | rcu_read_lock(); |
283 | dev = dev_get_by_index_rcu(net, mc_lst->ifindex); | 298 | dev = dev_get_by_index_rcu(net, mc_lst->ifindex); |
@@ -290,11 +305,13 @@ void ipv6_sock_mc_close(struct sock *sk) | |||
290 | } else | 305 | } else |
291 | (void) ip6_mc_leave_src(sk, mc_lst, NULL); | 306 | (void) ip6_mc_leave_src(sk, mc_lst, NULL); |
292 | rcu_read_unlock(); | 307 | rcu_read_unlock(); |
293 | sock_kfree_s(sk, mc_lst, sizeof(*mc_lst)); | ||
294 | 308 | ||
295 | write_lock_bh(&ipv6_sk_mc_lock); | 309 | atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc); |
310 | call_rcu(&mc_lst->rcu, ipv6_mc_socklist_reclaim); | ||
311 | |||
312 | spin_lock(&ipv6_sk_mc_lock); | ||
296 | } | 313 | } |
297 | write_unlock_bh(&ipv6_sk_mc_lock); | 314 | spin_unlock(&ipv6_sk_mc_lock); |
298 | } | 315 | } |
299 | 316 | ||
300 | int ip6_mc_source(int add, int omode, struct sock *sk, | 317 | int ip6_mc_source(int add, int omode, struct sock *sk, |
@@ -328,8 +345,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk, | |||
328 | 345 | ||
329 | err = -EADDRNOTAVAIL; | 346 | err = -EADDRNOTAVAIL; |
330 | 347 | ||
331 | read_lock(&ipv6_sk_mc_lock); | 348 | for_each_pmc_rcu(inet6, pmc) { |
332 | for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { | ||
333 | if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface) | 349 | if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface) |
334 | continue; | 350 | continue; |
335 | if (ipv6_addr_equal(&pmc->addr, group)) | 351 | if (ipv6_addr_equal(&pmc->addr, group)) |
@@ -428,7 +444,6 @@ int ip6_mc_source(int add, int omode, struct sock *sk, | |||
428 | done: | 444 | done: |
429 | if (pmclocked) | 445 | if (pmclocked) |
430 | write_unlock(&pmc->sflock); | 446 | write_unlock(&pmc->sflock); |
431 | read_unlock(&ipv6_sk_mc_lock); | ||
432 | read_unlock_bh(&idev->lock); | 447 | read_unlock_bh(&idev->lock); |
433 | rcu_read_unlock(); | 448 | rcu_read_unlock(); |
434 | if (leavegroup) | 449 | if (leavegroup) |
@@ -466,14 +481,13 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf) | |||
466 | dev = idev->dev; | 481 | dev = idev->dev; |
467 | 482 | ||
468 | err = 0; | 483 | err = 0; |
469 | read_lock(&ipv6_sk_mc_lock); | ||
470 | 484 | ||
471 | if (gsf->gf_fmode == MCAST_INCLUDE && gsf->gf_numsrc == 0) { | 485 | if (gsf->gf_fmode == MCAST_INCLUDE && gsf->gf_numsrc == 0) { |
472 | leavegroup = 1; | 486 | leavegroup = 1; |
473 | goto done; | 487 | goto done; |
474 | } | 488 | } |
475 | 489 | ||
476 | for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { | 490 | for_each_pmc_rcu(inet6, pmc) { |
477 | if (pmc->ifindex != gsf->gf_interface) | 491 | if (pmc->ifindex != gsf->gf_interface) |
478 | continue; | 492 | continue; |
479 | if (ipv6_addr_equal(&pmc->addr, group)) | 493 | if (ipv6_addr_equal(&pmc->addr, group)) |
@@ -521,7 +535,6 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf) | |||
521 | write_unlock(&pmc->sflock); | 535 | write_unlock(&pmc->sflock); |
522 | err = 0; | 536 | err = 0; |
523 | done: | 537 | done: |
524 | read_unlock(&ipv6_sk_mc_lock); | ||
525 | read_unlock_bh(&idev->lock); | 538 | read_unlock_bh(&idev->lock); |
526 | rcu_read_unlock(); | 539 | rcu_read_unlock(); |
527 | if (leavegroup) | 540 | if (leavegroup) |
@@ -562,7 +575,7 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf, | |||
562 | * so reading the list is safe. | 575 | * so reading the list is safe. |
563 | */ | 576 | */ |
564 | 577 | ||
565 | for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { | 578 | for_each_pmc_rcu(inet6, pmc) { |
566 | if (pmc->ifindex != gsf->gf_interface) | 579 | if (pmc->ifindex != gsf->gf_interface) |
567 | continue; | 580 | continue; |
568 | if (ipv6_addr_equal(group, &pmc->addr)) | 581 | if (ipv6_addr_equal(group, &pmc->addr)) |
@@ -612,13 +625,13 @@ int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr, | |||
612 | struct ip6_sf_socklist *psl; | 625 | struct ip6_sf_socklist *psl; |
613 | int rv = 1; | 626 | int rv = 1; |
614 | 627 | ||
615 | read_lock(&ipv6_sk_mc_lock); | 628 | rcu_read_lock(); |
616 | for (mc = np->ipv6_mc_list; mc; mc = mc->next) { | 629 | for_each_pmc_rcu(np, mc) { |
617 | if (ipv6_addr_equal(&mc->addr, mc_addr)) | 630 | if (ipv6_addr_equal(&mc->addr, mc_addr)) |
618 | break; | 631 | break; |
619 | } | 632 | } |
620 | if (!mc) { | 633 | if (!mc) { |
621 | read_unlock(&ipv6_sk_mc_lock); | 634 | rcu_read_unlock(); |
622 | return 1; | 635 | return 1; |
623 | } | 636 | } |
624 | read_lock(&mc->sflock); | 637 | read_lock(&mc->sflock); |
@@ -638,7 +651,7 @@ int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr, | |||
638 | rv = 0; | 651 | rv = 0; |
639 | } | 652 | } |
640 | read_unlock(&mc->sflock); | 653 | read_unlock(&mc->sflock); |
641 | read_unlock(&ipv6_sk_mc_lock); | 654 | rcu_read_unlock(); |
642 | 655 | ||
643 | return rv; | 656 | return rv; |
644 | } | 657 | } |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 998d6d27e7cf..2342545a5ee9 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -141,18 +141,18 @@ struct neigh_table nd_tbl = { | |||
141 | .proxy_redo = pndisc_redo, | 141 | .proxy_redo = pndisc_redo, |
142 | .id = "ndisc_cache", | 142 | .id = "ndisc_cache", |
143 | .parms = { | 143 | .parms = { |
144 | .tbl = &nd_tbl, | 144 | .tbl = &nd_tbl, |
145 | .base_reachable_time = 30 * HZ, | 145 | .base_reachable_time = ND_REACHABLE_TIME, |
146 | .retrans_time = 1 * HZ, | 146 | .retrans_time = ND_RETRANS_TIMER, |
147 | .gc_staletime = 60 * HZ, | 147 | .gc_staletime = 60 * HZ, |
148 | .reachable_time = 30 * HZ, | 148 | .reachable_time = ND_REACHABLE_TIME, |
149 | .delay_probe_time = 5 * HZ, | 149 | .delay_probe_time = 5 * HZ, |
150 | .queue_len = 3, | 150 | .queue_len = 3, |
151 | .ucast_probes = 3, | 151 | .ucast_probes = 3, |
152 | .mcast_probes = 3, | 152 | .mcast_probes = 3, |
153 | .anycast_delay = 1 * HZ, | 153 | .anycast_delay = 1 * HZ, |
154 | .proxy_delay = (8 * HZ) / 10, | 154 | .proxy_delay = (8 * HZ) / 10, |
155 | .proxy_qlen = 64, | 155 | .proxy_qlen = 64, |
156 | }, | 156 | }, |
157 | .gc_interval = 30 * HZ, | 157 | .gc_interval = 30 * HZ, |
158 | .gc_thresh1 = 128, | 158 | .gc_thresh1 = 128, |
@@ -1259,7 +1259,8 @@ static void ndisc_router_discovery(struct sk_buff *skb) | |||
1259 | if (ra_msg->icmph.icmp6_hop_limit) { | 1259 | if (ra_msg->icmph.icmp6_hop_limit) { |
1260 | in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit; | 1260 | in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit; |
1261 | if (rt) | 1261 | if (rt) |
1262 | rt->dst.metrics[RTAX_HOPLIMIT-1] = ra_msg->icmph.icmp6_hop_limit; | 1262 | dst_metric_set(&rt->dst, RTAX_HOPLIMIT, |
1263 | ra_msg->icmph.icmp6_hop_limit); | ||
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | skip_defrtr: | 1266 | skip_defrtr: |
@@ -1377,7 +1378,7 @@ skip_linkparms: | |||
1377 | in6_dev->cnf.mtu6 = mtu; | 1378 | in6_dev->cnf.mtu6 = mtu; |
1378 | 1379 | ||
1379 | if (rt) | 1380 | if (rt) |
1380 | rt->dst.metrics[RTAX_MTU-1] = mtu; | 1381 | dst_metric_set(&rt->dst, RTAX_MTU, mtu); |
1381 | 1382 | ||
1382 | rt6_mtu_change(skb->dev, mtu); | 1383 | rt6_mtu_change(skb->dev, mtu); |
1383 | } | 1384 | } |
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c index 7155b2451d7c..35915e8617f0 100644 --- a/net/ipv6/netfilter.c +++ b/net/ipv6/netfilter.c | |||
@@ -18,10 +18,8 @@ int ip6_route_me_harder(struct sk_buff *skb) | |||
18 | struct flowi fl = { | 18 | struct flowi fl = { |
19 | .oif = skb->sk ? skb->sk->sk_bound_dev_if : 0, | 19 | .oif = skb->sk ? skb->sk->sk_bound_dev_if : 0, |
20 | .mark = skb->mark, | 20 | .mark = skb->mark, |
21 | .nl_u = | 21 | .fl6_dst = iph->daddr, |
22 | { .ip6_u = | 22 | .fl6_src = iph->saddr, |
23 | { .daddr = iph->daddr, | ||
24 | .saddr = iph->saddr, } }, | ||
25 | }; | 23 | }; |
26 | 24 | ||
27 | dst = ip6_route_output(net, skb->sk, &fl); | 25 | dst = ip6_route_output(net, skb->sk, &fl); |
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile index 0a432c9b0795..abfee91ce816 100644 --- a/net/ipv6/netfilter/Makefile +++ b/net/ipv6/netfilter/Makefile | |||
@@ -11,13 +11,13 @@ obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o | |||
11 | obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o | 11 | obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o |
12 | 12 | ||
13 | # objects for l3 independent conntrack | 13 | # objects for l3 independent conntrack |
14 | nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o | 14 | nf_conntrack_ipv6-y := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o |
15 | 15 | ||
16 | # l3 independent conntrack | 16 | # l3 independent conntrack |
17 | obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o nf_defrag_ipv6.o | 17 | obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o nf_defrag_ipv6.o |
18 | 18 | ||
19 | # defrag | 19 | # defrag |
20 | nf_defrag_ipv6-objs := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o | 20 | nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o |
21 | obj-$(CONFIG_NF_DEFRAG_IPV6) += nf_defrag_ipv6.o | 21 | obj-$(CONFIG_NF_DEFRAG_IPV6) += nf_defrag_ipv6.o |
22 | 22 | ||
23 | # matches | 23 | # matches |
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 455582384ece..7d227c644f72 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
@@ -897,42 +897,25 @@ get_counters(const struct xt_table_info *t, | |||
897 | struct ip6t_entry *iter; | 897 | struct ip6t_entry *iter; |
898 | unsigned int cpu; | 898 | unsigned int cpu; |
899 | unsigned int i; | 899 | unsigned int i; |
900 | unsigned int curcpu = get_cpu(); | ||
901 | |||
902 | /* Instead of clearing (by a previous call to memset()) | ||
903 | * the counters and using adds, we set the counters | ||
904 | * with data used by 'current' CPU | ||
905 | * | ||
906 | * Bottom half has to be disabled to prevent deadlock | ||
907 | * if new softirq were to run and call ipt_do_table | ||
908 | */ | ||
909 | local_bh_disable(); | ||
910 | i = 0; | ||
911 | xt_entry_foreach(iter, t->entries[curcpu], t->size) { | ||
912 | SET_COUNTER(counters[i], iter->counters.bcnt, | ||
913 | iter->counters.pcnt); | ||
914 | ++i; | ||
915 | } | ||
916 | local_bh_enable(); | ||
917 | /* Processing counters from other cpus, we can let bottom half enabled, | ||
918 | * (preemption is disabled) | ||
919 | */ | ||
920 | 900 | ||
921 | for_each_possible_cpu(cpu) { | 901 | for_each_possible_cpu(cpu) { |
922 | if (cpu == curcpu) | 902 | seqlock_t *lock = &per_cpu(xt_info_locks, cpu).lock; |
923 | continue; | 903 | |
924 | i = 0; | 904 | i = 0; |
925 | local_bh_disable(); | ||
926 | xt_info_wrlock(cpu); | ||
927 | xt_entry_foreach(iter, t->entries[cpu], t->size) { | 905 | xt_entry_foreach(iter, t->entries[cpu], t->size) { |
928 | ADD_COUNTER(counters[i], iter->counters.bcnt, | 906 | u64 bcnt, pcnt; |
929 | iter->counters.pcnt); | 907 | unsigned int start; |
908 | |||
909 | do { | ||
910 | start = read_seqbegin(lock); | ||
911 | bcnt = iter->counters.bcnt; | ||
912 | pcnt = iter->counters.pcnt; | ||
913 | } while (read_seqretry(lock, start)); | ||
914 | |||
915 | ADD_COUNTER(counters[i], bcnt, pcnt); | ||
930 | ++i; | 916 | ++i; |
931 | } | 917 | } |
932 | xt_info_wrunlock(cpu); | ||
933 | local_bh_enable(); | ||
934 | } | 918 | } |
935 | put_cpu(); | ||
936 | } | 919 | } |
937 | 920 | ||
938 | static struct xt_counters *alloc_counters(const struct xt_table *table) | 921 | static struct xt_counters *alloc_counters(const struct xt_table *table) |
@@ -945,7 +928,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table) | |||
945 | (other than comefrom, which userspace doesn't care | 928 | (other than comefrom, which userspace doesn't care |
946 | about). */ | 929 | about). */ |
947 | countersize = sizeof(struct xt_counters) * private->number; | 930 | countersize = sizeof(struct xt_counters) * private->number; |
948 | counters = vmalloc(countersize); | 931 | counters = vzalloc(countersize); |
949 | 932 | ||
950 | if (counters == NULL) | 933 | if (counters == NULL) |
951 | return ERR_PTR(-ENOMEM); | 934 | return ERR_PTR(-ENOMEM); |
@@ -1216,7 +1199,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, | |||
1216 | struct ip6t_entry *iter; | 1199 | struct ip6t_entry *iter; |
1217 | 1200 | ||
1218 | ret = 0; | 1201 | ret = 0; |
1219 | counters = vmalloc(num_counters * sizeof(struct xt_counters)); | 1202 | counters = vzalloc(num_counters * sizeof(struct xt_counters)); |
1220 | if (!counters) { | 1203 | if (!counters) { |
1221 | ret = -ENOMEM; | 1204 | ret = -ENOMEM; |
1222 | goto out; | 1205 | goto out; |
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index 2933396e0281..bf998feac14e 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -124,7 +124,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb) | |||
124 | skb_reset_network_header(nskb); | 124 | skb_reset_network_header(nskb); |
125 | ip6h = ipv6_hdr(nskb); | 125 | ip6h = ipv6_hdr(nskb); |
126 | ip6h->version = 6; | 126 | ip6h->version = 6; |
127 | ip6h->hop_limit = dst_metric(dst, RTAX_HOPLIMIT); | 127 | ip6h->hop_limit = ip6_dst_hoplimit(dst); |
128 | ip6h->nexthdr = IPPROTO_TCP; | 128 | ip6h->nexthdr = IPPROTO_TCP; |
129 | ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr); | 129 | ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr); |
130 | ipv6_addr_copy(&ip6h->daddr, &oip6h->saddr); | 130 | ipv6_addr_copy(&ip6h->daddr, &oip6h->saddr); |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 0f2766453759..07beeb06f752 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -104,26 +104,22 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
104 | unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr, | 104 | unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr, |
105 | const struct in6_addr *daddr, u32 rnd) | 105 | const struct in6_addr *daddr, u32 rnd) |
106 | { | 106 | { |
107 | u32 a, b, c; | 107 | u32 c; |
108 | 108 | ||
109 | a = (__force u32)saddr->s6_addr32[0]; | 109 | c = jhash_3words((__force u32)saddr->s6_addr32[0], |
110 | b = (__force u32)saddr->s6_addr32[1]; | 110 | (__force u32)saddr->s6_addr32[1], |
111 | c = (__force u32)saddr->s6_addr32[2]; | 111 | (__force u32)saddr->s6_addr32[2], |
112 | 112 | rnd); | |
113 | a += JHASH_GOLDEN_RATIO; | 113 | |
114 | b += JHASH_GOLDEN_RATIO; | 114 | c = jhash_3words((__force u32)saddr->s6_addr32[3], |
115 | c += rnd; | 115 | (__force u32)daddr->s6_addr32[0], |
116 | __jhash_mix(a, b, c); | 116 | (__force u32)daddr->s6_addr32[1], |
117 | 117 | c); | |
118 | a += (__force u32)saddr->s6_addr32[3]; | 118 | |
119 | b += (__force u32)daddr->s6_addr32[0]; | 119 | c = jhash_3words((__force u32)daddr->s6_addr32[2], |
120 | c += (__force u32)daddr->s6_addr32[1]; | 120 | (__force u32)daddr->s6_addr32[3], |
121 | __jhash_mix(a, b, c); | 121 | (__force u32)id, |
122 | 122 | c); | |
123 | a += (__force u32)daddr->s6_addr32[2]; | ||
124 | b += (__force u32)daddr->s6_addr32[3]; | ||
125 | c += (__force u32)id; | ||
126 | __jhash_mix(a, b, c); | ||
127 | 123 | ||
128 | return c & (INETFRAGS_HASHSZ - 1); | 124 | return c & (INETFRAGS_HASHSZ - 1); |
129 | } | 125 | } |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 96455ffb76fb..373bd0416f69 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -76,6 +76,8 @@ | |||
76 | 76 | ||
77 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort); | 77 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort); |
78 | static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); | 78 | static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); |
79 | static unsigned int ip6_default_advmss(const struct dst_entry *dst); | ||
80 | static unsigned int ip6_default_mtu(const struct dst_entry *dst); | ||
79 | static struct dst_entry *ip6_negative_advice(struct dst_entry *); | 81 | static struct dst_entry *ip6_negative_advice(struct dst_entry *); |
80 | static void ip6_dst_destroy(struct dst_entry *); | 82 | static void ip6_dst_destroy(struct dst_entry *); |
81 | static void ip6_dst_ifdown(struct dst_entry *, | 83 | static void ip6_dst_ifdown(struct dst_entry *, |
@@ -103,6 +105,8 @@ static struct dst_ops ip6_dst_ops_template = { | |||
103 | .gc = ip6_dst_gc, | 105 | .gc = ip6_dst_gc, |
104 | .gc_thresh = 1024, | 106 | .gc_thresh = 1024, |
105 | .check = ip6_dst_check, | 107 | .check = ip6_dst_check, |
108 | .default_advmss = ip6_default_advmss, | ||
109 | .default_mtu = ip6_default_mtu, | ||
106 | .destroy = ip6_dst_destroy, | 110 | .destroy = ip6_dst_destroy, |
107 | .ifdown = ip6_dst_ifdown, | 111 | .ifdown = ip6_dst_ifdown, |
108 | .negative_advice = ip6_negative_advice, | 112 | .negative_advice = ip6_negative_advice, |
@@ -129,7 +133,6 @@ static struct rt6_info ip6_null_entry_template = { | |||
129 | .__use = 1, | 133 | .__use = 1, |
130 | .obsolete = -1, | 134 | .obsolete = -1, |
131 | .error = -ENETUNREACH, | 135 | .error = -ENETUNREACH, |
132 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | ||
133 | .input = ip6_pkt_discard, | 136 | .input = ip6_pkt_discard, |
134 | .output = ip6_pkt_discard_out, | 137 | .output = ip6_pkt_discard_out, |
135 | }, | 138 | }, |
@@ -150,7 +153,6 @@ static struct rt6_info ip6_prohibit_entry_template = { | |||
150 | .__use = 1, | 153 | .__use = 1, |
151 | .obsolete = -1, | 154 | .obsolete = -1, |
152 | .error = -EACCES, | 155 | .error = -EACCES, |
153 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | ||
154 | .input = ip6_pkt_prohibit, | 156 | .input = ip6_pkt_prohibit, |
155 | .output = ip6_pkt_prohibit_out, | 157 | .output = ip6_pkt_prohibit_out, |
156 | }, | 158 | }, |
@@ -166,7 +168,6 @@ static struct rt6_info ip6_blk_hole_entry_template = { | |||
166 | .__use = 1, | 168 | .__use = 1, |
167 | .obsolete = -1, | 169 | .obsolete = -1, |
168 | .error = -EINVAL, | 170 | .error = -EINVAL, |
169 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | ||
170 | .input = dst_discard, | 171 | .input = dst_discard, |
171 | .output = dst_discard, | 172 | .output = dst_discard, |
172 | }, | 173 | }, |
@@ -188,11 +189,29 @@ static void ip6_dst_destroy(struct dst_entry *dst) | |||
188 | { | 189 | { |
189 | struct rt6_info *rt = (struct rt6_info *)dst; | 190 | struct rt6_info *rt = (struct rt6_info *)dst; |
190 | struct inet6_dev *idev = rt->rt6i_idev; | 191 | struct inet6_dev *idev = rt->rt6i_idev; |
192 | struct inet_peer *peer = rt->rt6i_peer; | ||
191 | 193 | ||
192 | if (idev != NULL) { | 194 | if (idev != NULL) { |
193 | rt->rt6i_idev = NULL; | 195 | rt->rt6i_idev = NULL; |
194 | in6_dev_put(idev); | 196 | in6_dev_put(idev); |
195 | } | 197 | } |
198 | if (peer) { | ||
199 | BUG_ON(!(rt->rt6i_flags & RTF_CACHE)); | ||
200 | rt->rt6i_peer = NULL; | ||
201 | inet_putpeer(peer); | ||
202 | } | ||
203 | } | ||
204 | |||
205 | void rt6_bind_peer(struct rt6_info *rt, int create) | ||
206 | { | ||
207 | struct inet_peer *peer; | ||
208 | |||
209 | if (WARN_ON(!(rt->rt6i_flags & RTF_CACHE))) | ||
210 | return; | ||
211 | |||
212 | peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create); | ||
213 | if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL) | ||
214 | inet_putpeer(peer); | ||
196 | } | 215 | } |
197 | 216 | ||
198 | static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | 217 | static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, |
@@ -558,11 +577,7 @@ struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr, | |||
558 | { | 577 | { |
559 | struct flowi fl = { | 578 | struct flowi fl = { |
560 | .oif = oif, | 579 | .oif = oif, |
561 | .nl_u = { | 580 | .fl6_dst = *daddr, |
562 | .ip6_u = { | ||
563 | .daddr = *daddr, | ||
564 | }, | ||
565 | }, | ||
566 | }; | 581 | }; |
567 | struct dst_entry *dst; | 582 | struct dst_entry *dst; |
568 | int flags = strict ? RT6_LOOKUP_F_IFACE : 0; | 583 | int flags = strict ? RT6_LOOKUP_F_IFACE : 0; |
@@ -778,13 +793,9 @@ void ip6_route_input(struct sk_buff *skb) | |||
778 | int flags = RT6_LOOKUP_F_HAS_SADDR; | 793 | int flags = RT6_LOOKUP_F_HAS_SADDR; |
779 | struct flowi fl = { | 794 | struct flowi fl = { |
780 | .iif = skb->dev->ifindex, | 795 | .iif = skb->dev->ifindex, |
781 | .nl_u = { | 796 | .fl6_dst = iph->daddr, |
782 | .ip6_u = { | 797 | .fl6_src = iph->saddr, |
783 | .daddr = iph->daddr, | 798 | .fl6_flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK, |
784 | .saddr = iph->saddr, | ||
785 | .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK, | ||
786 | }, | ||
787 | }, | ||
788 | .mark = skb->mark, | 799 | .mark = skb->mark, |
789 | .proto = iph->nexthdr, | 800 | .proto = iph->nexthdr, |
790 | }; | 801 | }; |
@@ -834,7 +845,7 @@ int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl | |||
834 | new->input = dst_discard; | 845 | new->input = dst_discard; |
835 | new->output = dst_discard; | 846 | new->output = dst_discard; |
836 | 847 | ||
837 | memcpy(new->metrics, ort->dst.metrics, RTAX_MAX*sizeof(u32)); | 848 | dst_copy_metrics(new, &ort->dst); |
838 | new->dev = ort->dst.dev; | 849 | new->dev = ort->dst.dev; |
839 | if (new->dev) | 850 | if (new->dev) |
840 | dev_hold(new->dev); | 851 | dev_hold(new->dev); |
@@ -918,18 +929,22 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
918 | if (mtu < dst_mtu(dst) && rt6->rt6i_dst.plen == 128) { | 929 | if (mtu < dst_mtu(dst) && rt6->rt6i_dst.plen == 128) { |
919 | rt6->rt6i_flags |= RTF_MODIFIED; | 930 | rt6->rt6i_flags |= RTF_MODIFIED; |
920 | if (mtu < IPV6_MIN_MTU) { | 931 | if (mtu < IPV6_MIN_MTU) { |
932 | u32 features = dst_metric(dst, RTAX_FEATURES); | ||
921 | mtu = IPV6_MIN_MTU; | 933 | mtu = IPV6_MIN_MTU; |
922 | dst->metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 934 | features |= RTAX_FEATURE_ALLFRAG; |
935 | dst_metric_set(dst, RTAX_FEATURES, features); | ||
923 | } | 936 | } |
924 | dst->metrics[RTAX_MTU-1] = mtu; | 937 | dst_metric_set(dst, RTAX_MTU, mtu); |
925 | call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst); | 938 | call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst); |
926 | } | 939 | } |
927 | } | 940 | } |
928 | 941 | ||
929 | static int ipv6_get_mtu(struct net_device *dev); | 942 | static unsigned int ip6_default_advmss(const struct dst_entry *dst) |
930 | |||
931 | static inline unsigned int ipv6_advmss(struct net *net, unsigned int mtu) | ||
932 | { | 943 | { |
944 | struct net_device *dev = dst->dev; | ||
945 | unsigned int mtu = dst_mtu(dst); | ||
946 | struct net *net = dev_net(dev); | ||
947 | |||
933 | mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr); | 948 | mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr); |
934 | 949 | ||
935 | if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss) | 950 | if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss) |
@@ -946,6 +961,20 @@ static inline unsigned int ipv6_advmss(struct net *net, unsigned int mtu) | |||
946 | return mtu; | 961 | return mtu; |
947 | } | 962 | } |
948 | 963 | ||
964 | static unsigned int ip6_default_mtu(const struct dst_entry *dst) | ||
965 | { | ||
966 | unsigned int mtu = IPV6_MIN_MTU; | ||
967 | struct inet6_dev *idev; | ||
968 | |||
969 | rcu_read_lock(); | ||
970 | idev = __in6_dev_get(dst->dev); | ||
971 | if (idev) | ||
972 | mtu = idev->cnf.mtu6; | ||
973 | rcu_read_unlock(); | ||
974 | |||
975 | return mtu; | ||
976 | } | ||
977 | |||
949 | static struct dst_entry *icmp6_dst_gc_list; | 978 | static struct dst_entry *icmp6_dst_gc_list; |
950 | static DEFINE_SPINLOCK(icmp6_dst_lock); | 979 | static DEFINE_SPINLOCK(icmp6_dst_lock); |
951 | 980 | ||
@@ -979,9 +1008,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, | |||
979 | rt->rt6i_idev = idev; | 1008 | rt->rt6i_idev = idev; |
980 | rt->rt6i_nexthop = neigh; | 1009 | rt->rt6i_nexthop = neigh; |
981 | atomic_set(&rt->dst.__refcnt, 1); | 1010 | atomic_set(&rt->dst.__refcnt, 1); |
982 | rt->dst.metrics[RTAX_HOPLIMIT-1] = 255; | 1011 | dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); |
983 | rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | ||
984 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst)); | ||
985 | rt->dst.output = ip6_output; | 1012 | rt->dst.output = ip6_output; |
986 | 1013 | ||
987 | #if 0 /* there's no chance to use these for ndisc */ | 1014 | #if 0 /* there's no chance to use these for ndisc */ |
@@ -1080,23 +1107,10 @@ out: | |||
1080 | Remove it only when all the things will work! | 1107 | Remove it only when all the things will work! |
1081 | */ | 1108 | */ |
1082 | 1109 | ||
1083 | static int ipv6_get_mtu(struct net_device *dev) | ||
1084 | { | ||
1085 | int mtu = IPV6_MIN_MTU; | ||
1086 | struct inet6_dev *idev; | ||
1087 | |||
1088 | rcu_read_lock(); | ||
1089 | idev = __in6_dev_get(dev); | ||
1090 | if (idev) | ||
1091 | mtu = idev->cnf.mtu6; | ||
1092 | rcu_read_unlock(); | ||
1093 | return mtu; | ||
1094 | } | ||
1095 | |||
1096 | int ip6_dst_hoplimit(struct dst_entry *dst) | 1110 | int ip6_dst_hoplimit(struct dst_entry *dst) |
1097 | { | 1111 | { |
1098 | int hoplimit = dst_metric(dst, RTAX_HOPLIMIT); | 1112 | int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT); |
1099 | if (hoplimit < 0) { | 1113 | if (hoplimit == 0) { |
1100 | struct net_device *dev = dst->dev; | 1114 | struct net_device *dev = dst->dev; |
1101 | struct inet6_dev *idev; | 1115 | struct inet6_dev *idev; |
1102 | 1116 | ||
@@ -1110,6 +1124,7 @@ int ip6_dst_hoplimit(struct dst_entry *dst) | |||
1110 | } | 1124 | } |
1111 | return hoplimit; | 1125 | return hoplimit; |
1112 | } | 1126 | } |
1127 | EXPORT_SYMBOL(ip6_dst_hoplimit); | ||
1113 | 1128 | ||
1114 | /* | 1129 | /* |
1115 | * | 1130 | * |
@@ -1295,17 +1310,11 @@ install_route: | |||
1295 | goto out; | 1310 | goto out; |
1296 | } | 1311 | } |
1297 | 1312 | ||
1298 | rt->dst.metrics[type - 1] = nla_get_u32(nla); | 1313 | dst_metric_set(&rt->dst, type, nla_get_u32(nla)); |
1299 | } | 1314 | } |
1300 | } | 1315 | } |
1301 | } | 1316 | } |
1302 | 1317 | ||
1303 | if (dst_metric(&rt->dst, RTAX_HOPLIMIT) == 0) | ||
1304 | rt->dst.metrics[RTAX_HOPLIMIT-1] = -1; | ||
1305 | if (!dst_mtu(&rt->dst)) | ||
1306 | rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); | ||
1307 | if (!dst_metric(&rt->dst, RTAX_ADVMSS)) | ||
1308 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst)); | ||
1309 | rt->dst.dev = dev; | 1318 | rt->dst.dev = dev; |
1310 | rt->rt6i_idev = idev; | 1319 | rt->rt6i_idev = idev; |
1311 | rt->rt6i_table = table; | 1320 | rt->rt6i_table = table; |
@@ -1463,12 +1472,8 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest, | |||
1463 | struct ip6rd_flowi rdfl = { | 1472 | struct ip6rd_flowi rdfl = { |
1464 | .fl = { | 1473 | .fl = { |
1465 | .oif = dev->ifindex, | 1474 | .oif = dev->ifindex, |
1466 | .nl_u = { | 1475 | .fl6_dst = *dest, |
1467 | .ip6_u = { | 1476 | .fl6_src = *src, |
1468 | .daddr = *dest, | ||
1469 | .saddr = *src, | ||
1470 | }, | ||
1471 | }, | ||
1472 | }, | 1477 | }, |
1473 | }; | 1478 | }; |
1474 | 1479 | ||
@@ -1534,10 +1539,6 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | |||
1534 | 1539 | ||
1535 | ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); | 1540 | ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); |
1536 | nrt->rt6i_nexthop = neigh_clone(neigh); | 1541 | nrt->rt6i_nexthop = neigh_clone(neigh); |
1537 | /* Reset pmtu, it may be better */ | ||
1538 | nrt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev); | ||
1539 | nrt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dev_net(neigh->dev), | ||
1540 | dst_mtu(&nrt->dst)); | ||
1541 | 1542 | ||
1542 | if (ip6_ins_rt(nrt)) | 1543 | if (ip6_ins_rt(nrt)) |
1543 | goto out; | 1544 | goto out; |
@@ -1565,11 +1566,16 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1565 | { | 1566 | { |
1566 | struct rt6_info *rt, *nrt; | 1567 | struct rt6_info *rt, *nrt; |
1567 | int allfrag = 0; | 1568 | int allfrag = 0; |
1568 | 1569 | again: | |
1569 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); | 1570 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); |
1570 | if (rt == NULL) | 1571 | if (rt == NULL) |
1571 | return; | 1572 | return; |
1572 | 1573 | ||
1574 | if (rt6_check_expired(rt)) { | ||
1575 | ip6_del_rt(rt); | ||
1576 | goto again; | ||
1577 | } | ||
1578 | |||
1573 | if (pmtu >= dst_mtu(&rt->dst)) | 1579 | if (pmtu >= dst_mtu(&rt->dst)) |
1574 | goto out; | 1580 | goto out; |
1575 | 1581 | ||
@@ -1596,9 +1602,12 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1596 | would return automatically. | 1602 | would return automatically. |
1597 | */ | 1603 | */ |
1598 | if (rt->rt6i_flags & RTF_CACHE) { | 1604 | if (rt->rt6i_flags & RTF_CACHE) { |
1599 | rt->dst.metrics[RTAX_MTU-1] = pmtu; | 1605 | dst_metric_set(&rt->dst, RTAX_MTU, pmtu); |
1600 | if (allfrag) | 1606 | if (allfrag) { |
1601 | rt->dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 1607 | u32 features = dst_metric(&rt->dst, RTAX_FEATURES); |
1608 | features |= RTAX_FEATURE_ALLFRAG; | ||
1609 | dst_metric_set(&rt->dst, RTAX_FEATURES, features); | ||
1610 | } | ||
1602 | dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires); | 1611 | dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires); |
1603 | rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES; | 1612 | rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES; |
1604 | goto out; | 1613 | goto out; |
@@ -1615,9 +1624,12 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1615 | nrt = rt6_alloc_clone(rt, daddr); | 1624 | nrt = rt6_alloc_clone(rt, daddr); |
1616 | 1625 | ||
1617 | if (nrt) { | 1626 | if (nrt) { |
1618 | nrt->dst.metrics[RTAX_MTU-1] = pmtu; | 1627 | dst_metric_set(&nrt->dst, RTAX_MTU, pmtu); |
1619 | if (allfrag) | 1628 | if (allfrag) { |
1620 | nrt->dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 1629 | u32 features = dst_metric(&nrt->dst, RTAX_FEATURES); |
1630 | features |= RTAX_FEATURE_ALLFRAG; | ||
1631 | dst_metric_set(&nrt->dst, RTAX_FEATURES, features); | ||
1632 | } | ||
1621 | 1633 | ||
1622 | /* According to RFC 1981, detecting PMTU increase shouldn't be | 1634 | /* According to RFC 1981, detecting PMTU increase shouldn't be |
1623 | * happened within 5 mins, the recommended timer is 10 mins. | 1635 | * happened within 5 mins, the recommended timer is 10 mins. |
@@ -1668,7 +1680,7 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) | |||
1668 | rt->dst.input = ort->dst.input; | 1680 | rt->dst.input = ort->dst.input; |
1669 | rt->dst.output = ort->dst.output; | 1681 | rt->dst.output = ort->dst.output; |
1670 | 1682 | ||
1671 | memcpy(rt->dst.metrics, ort->dst.metrics, RTAX_MAX*sizeof(u32)); | 1683 | dst_copy_metrics(&rt->dst, &ort->dst); |
1672 | rt->dst.error = ort->dst.error; | 1684 | rt->dst.error = ort->dst.error; |
1673 | rt->dst.dev = ort->dst.dev; | 1685 | rt->dst.dev = ort->dst.dev; |
1674 | if (rt->dst.dev) | 1686 | if (rt->dst.dev) |
@@ -1960,9 +1972,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1960 | rt->dst.output = ip6_output; | 1972 | rt->dst.output = ip6_output; |
1961 | rt->rt6i_dev = net->loopback_dev; | 1973 | rt->rt6i_dev = net->loopback_dev; |
1962 | rt->rt6i_idev = idev; | 1974 | rt->rt6i_idev = idev; |
1963 | rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | 1975 | dst_metric_set(&rt->dst, RTAX_HOPLIMIT, -1); |
1964 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst)); | ||
1965 | rt->dst.metrics[RTAX_HOPLIMIT-1] = -1; | ||
1966 | rt->dst.obsolete = -1; | 1976 | rt->dst.obsolete = -1; |
1967 | 1977 | ||
1968 | rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; | 1978 | rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; |
@@ -1999,11 +2009,11 @@ struct arg_dev_net { | |||
1999 | 2009 | ||
2000 | static int fib6_ifdown(struct rt6_info *rt, void *arg) | 2010 | static int fib6_ifdown(struct rt6_info *rt, void *arg) |
2001 | { | 2011 | { |
2002 | struct net_device *dev = ((struct arg_dev_net *)arg)->dev; | 2012 | const struct arg_dev_net *adn = arg; |
2003 | struct net *net = ((struct arg_dev_net *)arg)->net; | 2013 | const struct net_device *dev = adn->dev; |
2004 | 2014 | ||
2005 | if (((void *)rt->rt6i_dev == dev || dev == NULL) && | 2015 | if ((rt->rt6i_dev == dev || dev == NULL) && |
2006 | rt != net->ipv6.ip6_null_entry) { | 2016 | rt != adn->net->ipv6.ip6_null_entry) { |
2007 | RT6_TRACE("deleted by ifdown %p\n", rt); | 2017 | RT6_TRACE("deleted by ifdown %p\n", rt); |
2008 | return -1; | 2018 | return -1; |
2009 | } | 2019 | } |
@@ -2031,7 +2041,6 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) | |||
2031 | { | 2041 | { |
2032 | struct rt6_mtu_change_arg *arg = (struct rt6_mtu_change_arg *) p_arg; | 2042 | struct rt6_mtu_change_arg *arg = (struct rt6_mtu_change_arg *) p_arg; |
2033 | struct inet6_dev *idev; | 2043 | struct inet6_dev *idev; |
2034 | struct net *net = dev_net(arg->dev); | ||
2035 | 2044 | ||
2036 | /* In IPv6 pmtu discovery is not optional, | 2045 | /* In IPv6 pmtu discovery is not optional, |
2037 | so that RTAX_MTU lock cannot disable it. | 2046 | so that RTAX_MTU lock cannot disable it. |
@@ -2062,8 +2071,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) | |||
2062 | (dst_mtu(&rt->dst) >= arg->mtu || | 2071 | (dst_mtu(&rt->dst) >= arg->mtu || |
2063 | (dst_mtu(&rt->dst) < arg->mtu && | 2072 | (dst_mtu(&rt->dst) < arg->mtu && |
2064 | dst_mtu(&rt->dst) == idev->cnf.mtu6))) { | 2073 | dst_mtu(&rt->dst) == idev->cnf.mtu6))) { |
2065 | rt->dst.metrics[RTAX_MTU-1] = arg->mtu; | 2074 | dst_metric_set(&rt->dst, RTAX_MTU, arg->mtu); |
2066 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, arg->mtu); | ||
2067 | } | 2075 | } |
2068 | return 0; | 2076 | return 0; |
2069 | } | 2077 | } |
@@ -2289,7 +2297,7 @@ static int rt6_fill_node(struct net *net, | |||
2289 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); | 2297 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); |
2290 | } | 2298 | } |
2291 | 2299 | ||
2292 | if (rtnetlink_put_metrics(skb, rt->dst.metrics) < 0) | 2300 | if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0) |
2293 | goto nla_put_failure; | 2301 | goto nla_put_failure; |
2294 | 2302 | ||
2295 | if (rt->dst.neighbour) | 2303 | if (rt->dst.neighbour) |
@@ -2465,8 +2473,6 @@ static int ip6_route_dev_notify(struct notifier_block *this, | |||
2465 | 2473 | ||
2466 | #ifdef CONFIG_PROC_FS | 2474 | #ifdef CONFIG_PROC_FS |
2467 | 2475 | ||
2468 | #define RT6_INFO_LEN (32 + 4 + 32 + 4 + 32 + 40 + 5 + 1) | ||
2469 | |||
2470 | struct rt6_proc_arg | 2476 | struct rt6_proc_arg |
2471 | { | 2477 | { |
2472 | char *buffer; | 2478 | char *buffer; |
@@ -2682,6 +2688,7 @@ static int __net_init ip6_route_net_init(struct net *net) | |||
2682 | net->ipv6.ip6_null_entry->dst.path = | 2688 | net->ipv6.ip6_null_entry->dst.path = |
2683 | (struct dst_entry *)net->ipv6.ip6_null_entry; | 2689 | (struct dst_entry *)net->ipv6.ip6_null_entry; |
2684 | net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops; | 2690 | net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops; |
2691 | dst_metric_set(&net->ipv6.ip6_null_entry->dst, RTAX_HOPLIMIT, 255); | ||
2685 | 2692 | ||
2686 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 2693 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
2687 | net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, | 2694 | net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, |
@@ -2692,6 +2699,7 @@ static int __net_init ip6_route_net_init(struct net *net) | |||
2692 | net->ipv6.ip6_prohibit_entry->dst.path = | 2699 | net->ipv6.ip6_prohibit_entry->dst.path = |
2693 | (struct dst_entry *)net->ipv6.ip6_prohibit_entry; | 2700 | (struct dst_entry *)net->ipv6.ip6_prohibit_entry; |
2694 | net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops; | 2701 | net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops; |
2702 | dst_metric_set(&net->ipv6.ip6_prohibit_entry->dst, RTAX_HOPLIMIT, 255); | ||
2695 | 2703 | ||
2696 | net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, | 2704 | net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, |
2697 | sizeof(*net->ipv6.ip6_blk_hole_entry), | 2705 | sizeof(*net->ipv6.ip6_blk_hole_entry), |
@@ -2701,6 +2709,7 @@ static int __net_init ip6_route_net_init(struct net *net) | |||
2701 | net->ipv6.ip6_blk_hole_entry->dst.path = | 2709 | net->ipv6.ip6_blk_hole_entry->dst.path = |
2702 | (struct dst_entry *)net->ipv6.ip6_blk_hole_entry; | 2710 | (struct dst_entry *)net->ipv6.ip6_blk_hole_entry; |
2703 | net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; | 2711 | net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; |
2712 | dst_metric_set(&net->ipv6.ip6_blk_hole_entry->dst, RTAX_HOPLIMIT, 255); | ||
2704 | #endif | 2713 | #endif |
2705 | 2714 | ||
2706 | net->ipv6.sysctl.flush_delay = 0; | 2715 | net->ipv6.sysctl.flush_delay = 0; |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 8c4d00c7cd2b..8ce38f10a547 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -731,10 +731,9 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
731 | } | 731 | } |
732 | 732 | ||
733 | { | 733 | { |
734 | struct flowi fl = { .nl_u = { .ip4_u = | 734 | struct flowi fl = { .fl4_dst = dst, |
735 | { .daddr = dst, | 735 | .fl4_src = tiph->saddr, |
736 | .saddr = tiph->saddr, | 736 | .fl4_tos = RT_TOS(tos), |
737 | .tos = RT_TOS(tos) } }, | ||
738 | .oif = tunnel->parms.link, | 737 | .oif = tunnel->parms.link, |
739 | .proto = IPPROTO_IPV6 }; | 738 | .proto = IPPROTO_IPV6 }; |
740 | if (ip_route_output_key(dev_net(dev), &rt, &fl)) { | 739 | if (ip_route_output_key(dev_net(dev), &rt, &fl)) { |
@@ -856,10 +855,9 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev) | |||
856 | iph = &tunnel->parms.iph; | 855 | iph = &tunnel->parms.iph; |
857 | 856 | ||
858 | if (iph->daddr) { | 857 | if (iph->daddr) { |
859 | struct flowi fl = { .nl_u = { .ip4_u = | 858 | struct flowi fl = { .fl4_dst = iph->daddr, |
860 | { .daddr = iph->daddr, | 859 | .fl4_src = iph->saddr, |
861 | .saddr = iph->saddr, | 860 | .fl4_tos = RT_TOS(iph->tos), |
862 | .tos = RT_TOS(iph->tos) } }, | ||
863 | .oif = tunnel->parms.link, | 861 | .oif = tunnel->parms.link, |
864 | .proto = IPPROTO_IPV6 }; | 862 | .proto = IPPROTO_IPV6 }; |
865 | struct rtable *rt; | 863 | struct rtable *rt; |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 7e41e2cbb85e..20aa95e37359 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -130,6 +130,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
130 | struct ipv6_pinfo *np = inet6_sk(sk); | 130 | struct ipv6_pinfo *np = inet6_sk(sk); |
131 | struct tcp_sock *tp = tcp_sk(sk); | 131 | struct tcp_sock *tp = tcp_sk(sk); |
132 | struct in6_addr *saddr = NULL, *final_p, final; | 132 | struct in6_addr *saddr = NULL, *final_p, final; |
133 | struct rt6_info *rt; | ||
133 | struct flowi fl; | 134 | struct flowi fl; |
134 | struct dst_entry *dst; | 135 | struct dst_entry *dst; |
135 | int addr_type; | 136 | int addr_type; |
@@ -280,6 +281,26 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
280 | sk->sk_gso_type = SKB_GSO_TCPV6; | 281 | sk->sk_gso_type = SKB_GSO_TCPV6; |
281 | __ip6_dst_store(sk, dst, NULL, NULL); | 282 | __ip6_dst_store(sk, dst, NULL, NULL); |
282 | 283 | ||
284 | rt = (struct rt6_info *) dst; | ||
285 | if (tcp_death_row.sysctl_tw_recycle && | ||
286 | !tp->rx_opt.ts_recent_stamp && | ||
287 | ipv6_addr_equal(&rt->rt6i_dst.addr, &np->daddr)) { | ||
288 | struct inet_peer *peer = rt6_get_peer(rt); | ||
289 | /* | ||
290 | * VJ's idea. We save last timestamp seen from | ||
291 | * the destination in peer table, when entering state | ||
292 | * TIME-WAIT * and initialize rx_opt.ts_recent from it, | ||
293 | * when trying new connection. | ||
294 | */ | ||
295 | if (peer) { | ||
296 | inet_peer_refcheck(peer); | ||
297 | if ((u32)get_seconds() - peer->tcp_ts_stamp <= TCP_PAWS_MSL) { | ||
298 | tp->rx_opt.ts_recent_stamp = peer->tcp_ts_stamp; | ||
299 | tp->rx_opt.ts_recent = peer->tcp_ts; | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | |||
283 | icsk->icsk_ext_hdr_len = 0; | 304 | icsk->icsk_ext_hdr_len = 0; |
284 | if (np->opt) | 305 | if (np->opt) |
285 | icsk->icsk_ext_hdr_len = (np->opt->opt_flen + | 306 | icsk->icsk_ext_hdr_len = (np->opt->opt_flen + |
@@ -906,12 +927,6 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { | |||
906 | }; | 927 | }; |
907 | #endif | 928 | #endif |
908 | 929 | ||
909 | static struct timewait_sock_ops tcp6_timewait_sock_ops = { | ||
910 | .twsk_obj_size = sizeof(struct tcp6_timewait_sock), | ||
911 | .twsk_unique = tcp_twsk_unique, | ||
912 | .twsk_destructor= tcp_twsk_destructor, | ||
913 | }; | ||
914 | |||
915 | static void __tcp_v6_send_check(struct sk_buff *skb, | 930 | static void __tcp_v6_send_check(struct sk_buff *skb, |
916 | struct in6_addr *saddr, struct in6_addr *daddr) | 931 | struct in6_addr *saddr, struct in6_addr *daddr) |
917 | { | 932 | { |
@@ -1176,6 +1191,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1176 | struct ipv6_pinfo *np = inet6_sk(sk); | 1191 | struct ipv6_pinfo *np = inet6_sk(sk); |
1177 | struct tcp_sock *tp = tcp_sk(sk); | 1192 | struct tcp_sock *tp = tcp_sk(sk); |
1178 | __u32 isn = TCP_SKB_CB(skb)->when; | 1193 | __u32 isn = TCP_SKB_CB(skb)->when; |
1194 | struct dst_entry *dst = NULL; | ||
1179 | #ifdef CONFIG_SYN_COOKIES | 1195 | #ifdef CONFIG_SYN_COOKIES |
1180 | int want_cookie = 0; | 1196 | int want_cookie = 0; |
1181 | #else | 1197 | #else |
@@ -1273,6 +1289,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1273 | TCP_ECN_create_request(req, tcp_hdr(skb)); | 1289 | TCP_ECN_create_request(req, tcp_hdr(skb)); |
1274 | 1290 | ||
1275 | if (!isn) { | 1291 | if (!isn) { |
1292 | struct inet_peer *peer = NULL; | ||
1293 | |||
1276 | if (ipv6_opt_accepted(sk, skb) || | 1294 | if (ipv6_opt_accepted(sk, skb) || |
1277 | np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || | 1295 | np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || |
1278 | np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { | 1296 | np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { |
@@ -1285,13 +1303,57 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1285 | if (!sk->sk_bound_dev_if && | 1303 | if (!sk->sk_bound_dev_if && |
1286 | ipv6_addr_type(&treq->rmt_addr) & IPV6_ADDR_LINKLOCAL) | 1304 | ipv6_addr_type(&treq->rmt_addr) & IPV6_ADDR_LINKLOCAL) |
1287 | treq->iif = inet6_iif(skb); | 1305 | treq->iif = inet6_iif(skb); |
1288 | if (!want_cookie) { | 1306 | |
1289 | isn = tcp_v6_init_sequence(skb); | 1307 | if (want_cookie) { |
1290 | } else { | ||
1291 | isn = cookie_v6_init_sequence(sk, skb, &req->mss); | 1308 | isn = cookie_v6_init_sequence(sk, skb, &req->mss); |
1292 | req->cookie_ts = tmp_opt.tstamp_ok; | 1309 | req->cookie_ts = tmp_opt.tstamp_ok; |
1310 | goto have_isn; | ||
1293 | } | 1311 | } |
1312 | |||
1313 | /* VJ's idea. We save last timestamp seen | ||
1314 | * from the destination in peer table, when entering | ||
1315 | * state TIME-WAIT, and check against it before | ||
1316 | * accepting new connection request. | ||
1317 | * | ||
1318 | * If "isn" is not zero, this request hit alive | ||
1319 | * timewait bucket, so that all the necessary checks | ||
1320 | * are made in the function processing timewait state. | ||
1321 | */ | ||
1322 | if (tmp_opt.saw_tstamp && | ||
1323 | tcp_death_row.sysctl_tw_recycle && | ||
1324 | (dst = inet6_csk_route_req(sk, req)) != NULL && | ||
1325 | (peer = rt6_get_peer((struct rt6_info *)dst)) != NULL && | ||
1326 | ipv6_addr_equal((struct in6_addr *)peer->daddr.a6, | ||
1327 | &treq->rmt_addr)) { | ||
1328 | inet_peer_refcheck(peer); | ||
1329 | if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && | ||
1330 | (s32)(peer->tcp_ts - req->ts_recent) > | ||
1331 | TCP_PAWS_WINDOW) { | ||
1332 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_PAWSPASSIVEREJECTED); | ||
1333 | goto drop_and_release; | ||
1334 | } | ||
1335 | } | ||
1336 | /* Kill the following clause, if you dislike this way. */ | ||
1337 | else if (!sysctl_tcp_syncookies && | ||
1338 | (sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) < | ||
1339 | (sysctl_max_syn_backlog >> 2)) && | ||
1340 | (!peer || !peer->tcp_ts_stamp) && | ||
1341 | (!dst || !dst_metric(dst, RTAX_RTT))) { | ||
1342 | /* Without syncookies last quarter of | ||
1343 | * backlog is filled with destinations, | ||
1344 | * proven to be alive. | ||
1345 | * It means that we continue to communicate | ||
1346 | * to destinations, already remembered | ||
1347 | * to the moment of synflood. | ||
1348 | */ | ||
1349 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: drop open request from %pI6/%u\n", | ||
1350 | &treq->rmt_addr, ntohs(tcp_hdr(skb)->source)); | ||
1351 | goto drop_and_release; | ||
1352 | } | ||
1353 | |||
1354 | isn = tcp_v6_init_sequence(skb); | ||
1294 | } | 1355 | } |
1356 | have_isn: | ||
1295 | tcp_rsk(req)->snt_isn = isn; | 1357 | tcp_rsk(req)->snt_isn = isn; |
1296 | 1358 | ||
1297 | security_inet_conn_request(sk, skb, req); | 1359 | security_inet_conn_request(sk, skb, req); |
@@ -1304,6 +1366,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1304 | inet6_csk_reqsk_queue_hash_add(sk, req, TCP_TIMEOUT_INIT); | 1366 | inet6_csk_reqsk_queue_hash_add(sk, req, TCP_TIMEOUT_INIT); |
1305 | return 0; | 1367 | return 0; |
1306 | 1368 | ||
1369 | drop_and_release: | ||
1370 | dst_release(dst); | ||
1307 | drop_and_free: | 1371 | drop_and_free: |
1308 | reqsk_free(req); | 1372 | reqsk_free(req); |
1309 | drop: | 1373 | drop: |
@@ -1382,28 +1446,9 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1382 | if (sk_acceptq_is_full(sk)) | 1446 | if (sk_acceptq_is_full(sk)) |
1383 | goto out_overflow; | 1447 | goto out_overflow; |
1384 | 1448 | ||
1385 | if (dst == NULL) { | 1449 | if (!dst) { |
1386 | struct in6_addr *final_p, final; | 1450 | dst = inet6_csk_route_req(sk, req); |
1387 | struct flowi fl; | 1451 | if (!dst) |
1388 | |||
1389 | memset(&fl, 0, sizeof(fl)); | ||
1390 | fl.proto = IPPROTO_TCP; | ||
1391 | ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); | ||
1392 | final_p = fl6_update_dst(&fl, opt, &final); | ||
1393 | ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr); | ||
1394 | fl.oif = sk->sk_bound_dev_if; | ||
1395 | fl.mark = sk->sk_mark; | ||
1396 | fl.fl_ip_dport = inet_rsk(req)->rmt_port; | ||
1397 | fl.fl_ip_sport = inet_rsk(req)->loc_port; | ||
1398 | security_req_classify_flow(req, &fl); | ||
1399 | |||
1400 | if (ip6_dst_lookup(sk, &dst, &fl)) | ||
1401 | goto out; | ||
1402 | |||
1403 | if (final_p) | ||
1404 | ipv6_addr_copy(&fl.fl6_dst, final_p); | ||
1405 | |||
1406 | if ((xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0) | ||
1407 | goto out; | 1452 | goto out; |
1408 | } | 1453 | } |
1409 | 1454 | ||
@@ -1476,7 +1521,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1476 | 1521 | ||
1477 | tcp_mtup_init(newsk); | 1522 | tcp_mtup_init(newsk); |
1478 | tcp_sync_mss(newsk, dst_mtu(dst)); | 1523 | tcp_sync_mss(newsk, dst_mtu(dst)); |
1479 | newtp->advmss = dst_metric(dst, RTAX_ADVMSS); | 1524 | newtp->advmss = dst_metric_advmss(dst); |
1480 | tcp_initialize_rcv_mss(newsk); | 1525 | tcp_initialize_rcv_mss(newsk); |
1481 | 1526 | ||
1482 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; | 1527 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; |
@@ -1818,19 +1863,51 @@ do_time_wait: | |||
1818 | goto discard_it; | 1863 | goto discard_it; |
1819 | } | 1864 | } |
1820 | 1865 | ||
1821 | static int tcp_v6_remember_stamp(struct sock *sk) | 1866 | static struct inet_peer *tcp_v6_get_peer(struct sock *sk, bool *release_it) |
1822 | { | 1867 | { |
1823 | /* Alas, not yet... */ | 1868 | struct rt6_info *rt = (struct rt6_info *) __sk_dst_get(sk); |
1824 | return 0; | 1869 | struct ipv6_pinfo *np = inet6_sk(sk); |
1870 | struct inet_peer *peer; | ||
1871 | |||
1872 | if (!rt || | ||
1873 | !ipv6_addr_equal(&np->daddr, &rt->rt6i_dst.addr)) { | ||
1874 | peer = inet_getpeer_v6(&np->daddr, 1); | ||
1875 | *release_it = true; | ||
1876 | } else { | ||
1877 | if (!rt->rt6i_peer) | ||
1878 | rt6_bind_peer(rt, 1); | ||
1879 | peer = rt->rt6i_peer; | ||
1880 | *release_it = false; | ||
1881 | } | ||
1882 | |||
1883 | return peer; | ||
1825 | } | 1884 | } |
1826 | 1885 | ||
1886 | static void *tcp_v6_tw_get_peer(struct sock *sk) | ||
1887 | { | ||
1888 | struct inet6_timewait_sock *tw6 = inet6_twsk(sk); | ||
1889 | struct inet_timewait_sock *tw = inet_twsk(sk); | ||
1890 | |||
1891 | if (tw->tw_family == AF_INET) | ||
1892 | return tcp_v4_tw_get_peer(sk); | ||
1893 | |||
1894 | return inet_getpeer_v6(&tw6->tw_v6_daddr, 1); | ||
1895 | } | ||
1896 | |||
1897 | static struct timewait_sock_ops tcp6_timewait_sock_ops = { | ||
1898 | .twsk_obj_size = sizeof(struct tcp6_timewait_sock), | ||
1899 | .twsk_unique = tcp_twsk_unique, | ||
1900 | .twsk_destructor= tcp_twsk_destructor, | ||
1901 | .twsk_getpeer = tcp_v6_tw_get_peer, | ||
1902 | }; | ||
1903 | |||
1827 | static const struct inet_connection_sock_af_ops ipv6_specific = { | 1904 | static const struct inet_connection_sock_af_ops ipv6_specific = { |
1828 | .queue_xmit = inet6_csk_xmit, | 1905 | .queue_xmit = inet6_csk_xmit, |
1829 | .send_check = tcp_v6_send_check, | 1906 | .send_check = tcp_v6_send_check, |
1830 | .rebuild_header = inet6_sk_rebuild_header, | 1907 | .rebuild_header = inet6_sk_rebuild_header, |
1831 | .conn_request = tcp_v6_conn_request, | 1908 | .conn_request = tcp_v6_conn_request, |
1832 | .syn_recv_sock = tcp_v6_syn_recv_sock, | 1909 | .syn_recv_sock = tcp_v6_syn_recv_sock, |
1833 | .remember_stamp = tcp_v6_remember_stamp, | 1910 | .get_peer = tcp_v6_get_peer, |
1834 | .net_header_len = sizeof(struct ipv6hdr), | 1911 | .net_header_len = sizeof(struct ipv6hdr), |
1835 | .setsockopt = ipv6_setsockopt, | 1912 | .setsockopt = ipv6_setsockopt, |
1836 | .getsockopt = ipv6_getsockopt, | 1913 | .getsockopt = ipv6_getsockopt, |
@@ -1862,7 +1939,7 @@ static const struct inet_connection_sock_af_ops ipv6_mapped = { | |||
1862 | .rebuild_header = inet_sk_rebuild_header, | 1939 | .rebuild_header = inet_sk_rebuild_header, |
1863 | .conn_request = tcp_v6_conn_request, | 1940 | .conn_request = tcp_v6_conn_request, |
1864 | .syn_recv_sock = tcp_v6_syn_recv_sock, | 1941 | .syn_recv_sock = tcp_v6_syn_recv_sock, |
1865 | .remember_stamp = tcp_v4_remember_stamp, | 1942 | .get_peer = tcp_v4_get_peer, |
1866 | .net_header_len = sizeof(struct iphdr), | 1943 | .net_header_len = sizeof(struct iphdr), |
1867 | .setsockopt = ipv6_setsockopt, | 1944 | .setsockopt = ipv6_setsockopt, |
1868 | .getsockopt = ipv6_getsockopt, | 1945 | .getsockopt = ipv6_getsockopt, |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 91def93bec85..9a009c66c8a3 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -54,8 +54,8 @@ int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2) | |||
54 | { | 54 | { |
55 | const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr; | 55 | const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr; |
56 | const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2); | 56 | const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2); |
57 | __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr; | 57 | __be32 sk1_rcv_saddr = sk_rcv_saddr(sk); |
58 | __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2); | 58 | __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2); |
59 | int sk_ipv6only = ipv6_only_sock(sk); | 59 | int sk_ipv6only = ipv6_only_sock(sk); |
60 | int sk2_ipv6only = inet_v6_ipv6only(sk2); | 60 | int sk2_ipv6only = inet_v6_ipv6only(sk2); |
61 | int addr_type = ipv6_addr_type(sk_rcv_saddr6); | 61 | int addr_type = ipv6_addr_type(sk_rcv_saddr6); |
@@ -227,7 +227,7 @@ begin: | |||
227 | 227 | ||
228 | if (result) { | 228 | if (result) { |
229 | exact_match: | 229 | exact_match: |
230 | if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) | 230 | if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2))) |
231 | result = NULL; | 231 | result = NULL; |
232 | else if (unlikely(compute_score2(result, net, saddr, sport, | 232 | else if (unlikely(compute_score2(result, net, saddr, sport, |
233 | daddr, hnum, dif) < badness)) { | 233 | daddr, hnum, dif) < badness)) { |
@@ -294,7 +294,7 @@ begin: | |||
294 | goto begin; | 294 | goto begin; |
295 | 295 | ||
296 | if (result) { | 296 | if (result) { |
297 | if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) | 297 | if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2))) |
298 | result = NULL; | 298 | result = NULL; |
299 | else if (unlikely(compute_score(result, net, hnum, saddr, sport, | 299 | else if (unlikely(compute_score(result, net, hnum, saddr, sport, |
300 | daddr, dport, dif) < badness)) { | 300 | daddr, dport, dif) < badness)) { |
@@ -602,7 +602,7 @@ static void flush_stack(struct sock **stack, unsigned int count, | |||
602 | 602 | ||
603 | sk = stack[i]; | 603 | sk = stack[i]; |
604 | if (skb1) { | 604 | if (skb1) { |
605 | if (sk_rcvqueues_full(sk, skb)) { | 605 | if (sk_rcvqueues_full(sk, skb1)) { |
606 | kfree_skb(skb1); | 606 | kfree_skb(skb1); |
607 | goto drop; | 607 | goto drop; |
608 | } | 608 | } |
@@ -1477,6 +1477,7 @@ struct proto udpv6_prot = { | |||
1477 | .compat_setsockopt = compat_udpv6_setsockopt, | 1477 | .compat_setsockopt = compat_udpv6_setsockopt, |
1478 | .compat_getsockopt = compat_udpv6_getsockopt, | 1478 | .compat_getsockopt = compat_udpv6_getsockopt, |
1479 | #endif | 1479 | #endif |
1480 | .clear_sk = sk_prot_clear_portaddr_nulls, | ||
1480 | }; | 1481 | }; |
1481 | 1482 | ||
1482 | static struct inet_protosw udpv6_protosw = { | 1483 | static struct inet_protosw udpv6_protosw = { |
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 5f48fadc27f7..986c4de5292e 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c | |||
@@ -55,6 +55,7 @@ struct proto udplitev6_prot = { | |||
55 | .compat_setsockopt = compat_udpv6_setsockopt, | 55 | .compat_setsockopt = compat_udpv6_setsockopt, |
56 | .compat_getsockopt = compat_udpv6_getsockopt, | 56 | .compat_getsockopt = compat_udpv6_getsockopt, |
57 | #endif | 57 | #endif |
58 | .clear_sk = sk_prot_clear_portaddr_nulls, | ||
58 | }; | 59 | }; |
59 | 60 | ||
60 | static struct inet_protosw udplite6_protosw = { | 61 | static struct inet_protosw udplite6_protosw = { |
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c index b809812c8d30..645cb968d450 100644 --- a/net/ipv6/xfrm6_mode_tunnel.c +++ b/net/ipv6/xfrm6_mode_tunnel.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <net/dsfield.h> | 14 | #include <net/dsfield.h> |
15 | #include <net/dst.h> | 15 | #include <net/dst.h> |
16 | #include <net/inet_ecn.h> | 16 | #include <net/inet_ecn.h> |
17 | #include <net/ip6_route.h> | ||
17 | #include <net/ipv6.h> | 18 | #include <net/ipv6.h> |
18 | #include <net/xfrm.h> | 19 | #include <net/xfrm.h> |
19 | 20 | ||
@@ -53,7 +54,7 @@ static int xfrm6_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) | |||
53 | if (x->props.flags & XFRM_STATE_NOECN) | 54 | if (x->props.flags & XFRM_STATE_NOECN) |
54 | dsfield &= ~INET_ECN_MASK; | 55 | dsfield &= ~INET_ECN_MASK; |
55 | ipv6_change_dsfield(top_iph, 0, dsfield); | 56 | ipv6_change_dsfield(top_iph, 0, dsfield); |
56 | top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT); | 57 | top_iph->hop_limit = ip6_dst_hoplimit(dst->child); |
57 | ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr); | 58 | ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr); |
58 | ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); | 59 | ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); |
59 | return 0; | 60 | return 0; |
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 6434bd5ce088..8e688b3de9ab 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/netfilter_ipv6.h> | 17 | #include <linux/netfilter_ipv6.h> |
18 | #include <net/dst.h> | 18 | #include <net/dst.h> |
19 | #include <net/ipv6.h> | 19 | #include <net/ipv6.h> |
20 | #include <net/ip6_route.h> | ||
20 | #include <net/xfrm.h> | 21 | #include <net/xfrm.h> |
21 | 22 | ||
22 | int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | 23 | int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
@@ -88,8 +89,21 @@ static int xfrm6_output_finish(struct sk_buff *skb) | |||
88 | return xfrm_output(skb); | 89 | return xfrm_output(skb); |
89 | } | 90 | } |
90 | 91 | ||
92 | static int __xfrm6_output(struct sk_buff *skb) | ||
93 | { | ||
94 | struct dst_entry *dst = skb_dst(skb); | ||
95 | struct xfrm_state *x = dst->xfrm; | ||
96 | |||
97 | if ((x && x->props.mode == XFRM_MODE_TUNNEL) && | ||
98 | ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || | ||
99 | dst_allfrag(skb_dst(skb)))) { | ||
100 | return ip6_fragment(skb, xfrm6_output_finish); | ||
101 | } | ||
102 | return xfrm6_output_finish(skb); | ||
103 | } | ||
104 | |||
91 | int xfrm6_output(struct sk_buff *skb) | 105 | int xfrm6_output(struct sk_buff *skb) |
92 | { | 106 | { |
93 | return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL, | 107 | return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL, |
94 | skb_dst(skb)->dev, xfrm6_output_finish); | 108 | skb_dst(skb)->dev, __xfrm6_output); |
95 | } | 109 | } |