aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/addrconf.c9
-rw-r--r--net/ipv6/af_inet6.c51
-rw-r--r--net/ipv6/ah6.c2
-rw-r--r--net/ipv6/datagram.c88
-rw-r--r--net/ipv6/esp6.c111
-rw-r--r--net/ipv6/exthdrs.c12
-rw-r--r--net/ipv6/fib6_rules.c19
-rw-r--r--net/ipv6/icmp.c226
-rw-r--r--net/ipv6/inet6_connection_sock.c83
-rw-r--r--net/ipv6/inet6_hashtables.c2
-rw-r--r--net/ipv6/ip6_fib.c4
-rw-r--r--net/ipv6/ip6_flowlabel.c6
-rw-r--r--net/ipv6/ip6_output.c158
-rw-r--r--net/ipv6/ip6_tunnel.c83
-rw-r--r--net/ipv6/ip6mr.c58
-rw-r--r--net/ipv6/ipv6_sockglue.c10
-rw-r--r--net/ipv6/mcast.c27
-rw-r--r--net/ipv6/mip6.c16
-rw-r--r--net/ipv6/ndisc.c24
-rw-r--r--net/ipv6/netfilter.c30
-rw-r--r--net/ipv6/netfilter/ip6_tables.c11
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c5
-rw-r--r--net/ipv6/netfilter/ip6t_REJECT.c21
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c3
-rw-r--r--net/ipv6/netfilter/nf_defrag_ipv6_hooks.c2
-rw-r--r--net/ipv6/raw.c106
-rw-r--r--net/ipv6/route.c215
-rw-r--r--net/ipv6/sit.c58
-rw-r--r--net/ipv6/syncookies.c31
-rw-r--r--net/ipv6/sysctl_net_ipv6.c18
-rw-r--r--net/ipv6/tcp_ipv6.c174
-rw-r--r--net/ipv6/udp.c96
-rw-r--r--net/ipv6/xfrm6_policy.c49
-rw-r--r--net/ipv6/xfrm6_state.c20
34 files changed, 1003 insertions, 825 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index fd6782e3a038..a7bda0757053 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -718,12 +718,9 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
718 struct inet6_ifaddr *ifa, *ifn; 718 struct inet6_ifaddr *ifa, *ifn;
719 struct inet6_dev *idev = ifp->idev; 719 struct inet6_dev *idev = ifp->idev;
720 int state; 720 int state;
721 int hash;
722 int deleted = 0, onlink = 0; 721 int deleted = 0, onlink = 0;
723 unsigned long expires = jiffies; 722 unsigned long expires = jiffies;
724 723
725 hash = ipv6_addr_hash(&ifp->addr);
726
727 spin_lock_bh(&ifp->state_lock); 724 spin_lock_bh(&ifp->state_lock);
728 state = ifp->state; 725 state = ifp->state;
729 ifp->state = INET6_IFADDR_STATE_DEAD; 726 ifp->state = INET6_IFADDR_STATE_DEAD;
@@ -1087,7 +1084,7 @@ static int ipv6_get_saddr_eval(struct net *net,
1087 case IPV6_SADDR_RULE_PRIVACY: 1084 case IPV6_SADDR_RULE_PRIVACY:
1088 { 1085 {
1089 /* Rule 7: Prefer public address 1086 /* Rule 7: Prefer public address
1090 * Note: prefer temprary address if use_tempaddr >= 2 1087 * Note: prefer temporary address if use_tempaddr >= 2
1091 */ 1088 */
1092 int preftmp = dst->prefs & (IPV6_PREFER_SRC_PUBLIC|IPV6_PREFER_SRC_TMP) ? 1089 int preftmp = dst->prefs & (IPV6_PREFER_SRC_PUBLIC|IPV6_PREFER_SRC_TMP) ?
1093 !!(dst->prefs & IPV6_PREFER_SRC_TMP) : 1090 !!(dst->prefs & IPV6_PREFER_SRC_TMP) :
@@ -1971,7 +1968,7 @@ ok:
1971 * to the stored lifetime since we'll 1968 * to the stored lifetime since we'll
1972 * be updating the timestamp below, 1969 * be updating the timestamp below,
1973 * else we'll set it back to the 1970 * else we'll set it back to the
1974 * minumum. 1971 * minimum.
1975 */ 1972 */
1976 if (prefered_lft != ifp->prefered_lft) { 1973 if (prefered_lft != ifp->prefered_lft) {
1977 valid_lft = stored_lft; 1974 valid_lft = stored_lft;
@@ -4540,7 +4537,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
4540 4537
4541 t = p->sysctl; 4538 t = p->sysctl;
4542 p->sysctl = NULL; 4539 p->sysctl = NULL;
4543 unregister_sysctl_table(t->sysctl_header); 4540 unregister_net_sysctl_table(t->sysctl_header);
4544 kfree(t->dev_name); 4541 kfree(t->dev_name);
4545 kfree(t); 4542 kfree(t);
4546} 4543}
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 978e80e2c4a8..afcc7099f96d 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -644,41 +644,34 @@ EXPORT_SYMBOL(inet6_unregister_protosw);
644 644
645int inet6_sk_rebuild_header(struct sock *sk) 645int inet6_sk_rebuild_header(struct sock *sk)
646{ 646{
647 int err;
648 struct dst_entry *dst;
649 struct ipv6_pinfo *np = inet6_sk(sk); 647 struct ipv6_pinfo *np = inet6_sk(sk);
648 struct dst_entry *dst;
650 649
651 dst = __sk_dst_check(sk, np->dst_cookie); 650 dst = __sk_dst_check(sk, np->dst_cookie);
652 651
653 if (dst == NULL) { 652 if (dst == NULL) {
654 struct inet_sock *inet = inet_sk(sk); 653 struct inet_sock *inet = inet_sk(sk);
655 struct in6_addr *final_p, final; 654 struct in6_addr *final_p, final;
656 struct flowi fl; 655 struct flowi6 fl6;
657 656
658 memset(&fl, 0, sizeof(fl)); 657 memset(&fl6, 0, sizeof(fl6));
659 fl.proto = sk->sk_protocol; 658 fl6.flowi6_proto = sk->sk_protocol;
660 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 659 ipv6_addr_copy(&fl6.daddr, &np->daddr);
661 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 660 ipv6_addr_copy(&fl6.saddr, &np->saddr);
662 fl.fl6_flowlabel = np->flow_label; 661 fl6.flowlabel = np->flow_label;
663 fl.oif = sk->sk_bound_dev_if; 662 fl6.flowi6_oif = sk->sk_bound_dev_if;
664 fl.mark = sk->sk_mark; 663 fl6.flowi6_mark = sk->sk_mark;
665 fl.fl_ip_dport = inet->inet_dport; 664 fl6.fl6_dport = inet->inet_dport;
666 fl.fl_ip_sport = inet->inet_sport; 665 fl6.fl6_sport = inet->inet_sport;
667 security_sk_classify_flow(sk, &fl); 666 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
668 667
669 final_p = fl6_update_dst(&fl, np->opt, &final); 668 final_p = fl6_update_dst(&fl6, np->opt, &final);
670 669
671 err = ip6_dst_lookup(sk, &dst, &fl); 670 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
672 if (err) { 671 if (IS_ERR(dst)) {
673 sk->sk_route_caps = 0; 672 sk->sk_route_caps = 0;
674 return err; 673 sk->sk_err_soft = -PTR_ERR(dst);
675 } 674 return PTR_ERR(dst);
676 if (final_p)
677 ipv6_addr_copy(&fl.fl6_dst, final_p);
678
679 if ((err = xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0) {
680 sk->sk_err_soft = -err;
681 return err;
682 } 675 }
683 676
684 __ip6_dst_store(sk, dst, NULL, NULL); 677 __ip6_dst_store(sk, dst, NULL, NULL);
@@ -772,7 +765,7 @@ out:
772 return err; 765 return err;
773} 766}
774 767
775static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features) 768static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, u32 features)
776{ 769{
777 struct sk_buff *segs = ERR_PTR(-EINVAL); 770 struct sk_buff *segs = ERR_PTR(-EINVAL);
778 struct ipv6hdr *ipv6h; 771 struct ipv6hdr *ipv6h;
@@ -1120,7 +1113,7 @@ static int __init inet6_init(void)
1120 /* 1113 /*
1121 * ipngwg API draft makes clear that the correct semantics 1114 * ipngwg API draft makes clear that the correct semantics
1122 * for TCP and UDP is to consider one TCP and UDP instance 1115 * for TCP and UDP is to consider one TCP and UDP instance
1123 * in a host availiable by both INET and INET6 APIs and 1116 * in a host available by both INET and INET6 APIs and
1124 * able to communicate via both network protocols. 1117 * able to communicate via both network protocols.
1125 */ 1118 */
1126 1119
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 1aba54ae53c4..2195ae651923 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -409,7 +409,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
409 409
410 ah->reserved = 0; 410 ah->reserved = 0;
411 ah->spi = x->id.spi; 411 ah->spi = x->id.spi;
412 ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output); 412 ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);
413 413
414 sg_init_table(sg, nfrags); 414 sg_init_table(sg, nfrags);
415 skb_to_sgvec(skb, sg, 0, skb->len); 415 skb_to_sgvec(skb, sg, 0, skb->len);
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 320bdb877eed..16560336eb72 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -40,7 +40,7 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
40 struct ipv6_pinfo *np = inet6_sk(sk); 40 struct ipv6_pinfo *np = inet6_sk(sk);
41 struct in6_addr *daddr, *final_p, final; 41 struct in6_addr *daddr, *final_p, final;
42 struct dst_entry *dst; 42 struct dst_entry *dst;
43 struct flowi fl; 43 struct flowi6 fl6;
44 struct ip6_flowlabel *flowlabel = NULL; 44 struct ip6_flowlabel *flowlabel = NULL;
45 struct ipv6_txoptions *opt; 45 struct ipv6_txoptions *opt;
46 int addr_type; 46 int addr_type;
@@ -59,11 +59,11 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
59 if (usin->sin6_family != AF_INET6) 59 if (usin->sin6_family != AF_INET6)
60 return -EAFNOSUPPORT; 60 return -EAFNOSUPPORT;
61 61
62 memset(&fl, 0, sizeof(fl)); 62 memset(&fl6, 0, sizeof(fl6));
63 if (np->sndflow) { 63 if (np->sndflow) {
64 fl.fl6_flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK; 64 fl6.flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK;
65 if (fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) { 65 if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {
66 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); 66 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
67 if (flowlabel == NULL) 67 if (flowlabel == NULL)
68 return -EINVAL; 68 return -EINVAL;
69 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst); 69 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst);
@@ -137,7 +137,7 @@ ipv4_connected:
137 } 137 }
138 138
139 ipv6_addr_copy(&np->daddr, daddr); 139 ipv6_addr_copy(&np->daddr, daddr);
140 np->flow_label = fl.fl6_flowlabel; 140 np->flow_label = fl6.flowlabel;
141 141
142 inet->inet_dport = usin->sin6_port; 142 inet->inet_dport = usin->sin6_port;
143 143
@@ -146,53 +146,46 @@ ipv4_connected:
146 * destination cache for it. 146 * destination cache for it.
147 */ 147 */
148 148
149 fl.proto = sk->sk_protocol; 149 fl6.flowi6_proto = sk->sk_protocol;
150 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 150 ipv6_addr_copy(&fl6.daddr, &np->daddr);
151 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 151 ipv6_addr_copy(&fl6.saddr, &np->saddr);
152 fl.oif = sk->sk_bound_dev_if; 152 fl6.flowi6_oif = sk->sk_bound_dev_if;
153 fl.mark = sk->sk_mark; 153 fl6.flowi6_mark = sk->sk_mark;
154 fl.fl_ip_dport = inet->inet_dport; 154 fl6.fl6_dport = inet->inet_dport;
155 fl.fl_ip_sport = inet->inet_sport; 155 fl6.fl6_sport = inet->inet_sport;
156 156
157 if (!fl.oif && (addr_type&IPV6_ADDR_MULTICAST)) 157 if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST))
158 fl.oif = np->mcast_oif; 158 fl6.flowi6_oif = np->mcast_oif;
159 159
160 security_sk_classify_flow(sk, &fl); 160 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
161 161
162 opt = flowlabel ? flowlabel->opt : np->opt; 162 opt = flowlabel ? flowlabel->opt : np->opt;
163 final_p = fl6_update_dst(&fl, opt, &final); 163 final_p = fl6_update_dst(&fl6, opt, &final);
164 164
165 err = ip6_dst_lookup(sk, &dst, &fl); 165 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
166 if (err) 166 err = 0;
167 if (IS_ERR(dst)) {
168 err = PTR_ERR(dst);
167 goto out; 169 goto out;
168 if (final_p)
169 ipv6_addr_copy(&fl.fl6_dst, final_p);
170
171 err = __xfrm_lookup(sock_net(sk), &dst, &fl, sk, XFRM_LOOKUP_WAIT);
172 if (err < 0) {
173 if (err == -EREMOTE)
174 err = ip6_dst_blackhole(sk, &dst, &fl);
175 if (err < 0)
176 goto out;
177 } 170 }
178 171
179 /* source address lookup done in ip6_dst_lookup */ 172 /* source address lookup done in ip6_dst_lookup */
180 173
181 if (ipv6_addr_any(&np->saddr)) 174 if (ipv6_addr_any(&np->saddr))
182 ipv6_addr_copy(&np->saddr, &fl.fl6_src); 175 ipv6_addr_copy(&np->saddr, &fl6.saddr);
183 176
184 if (ipv6_addr_any(&np->rcv_saddr)) { 177 if (ipv6_addr_any(&np->rcv_saddr)) {
185 ipv6_addr_copy(&np->rcv_saddr, &fl.fl6_src); 178 ipv6_addr_copy(&np->rcv_saddr, &fl6.saddr);
186 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 179 inet->inet_rcv_saddr = LOOPBACK4_IPV6;
187 if (sk->sk_prot->rehash) 180 if (sk->sk_prot->rehash)
188 sk->sk_prot->rehash(sk); 181 sk->sk_prot->rehash(sk);
189 } 182 }
190 183
191 ip6_dst_store(sk, dst, 184 ip6_dst_store(sk, dst,
192 ipv6_addr_equal(&fl.fl6_dst, &np->daddr) ? 185 ipv6_addr_equal(&fl6.daddr, &np->daddr) ?
193 &np->daddr : NULL, 186 &np->daddr : NULL,
194#ifdef CONFIG_IPV6_SUBTREES 187#ifdef CONFIG_IPV6_SUBTREES
195 ipv6_addr_equal(&fl.fl6_src, &np->saddr) ? 188 ipv6_addr_equal(&fl6.saddr, &np->saddr) ?
196 &np->saddr : 189 &np->saddr :
197#endif 190#endif
198 NULL); 191 NULL);
@@ -238,7 +231,7 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
238 kfree_skb(skb); 231 kfree_skb(skb);
239} 232}
240 233
241void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info) 234void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info)
242{ 235{
243 struct ipv6_pinfo *np = inet6_sk(sk); 236 struct ipv6_pinfo *np = inet6_sk(sk);
244 struct sock_exterr_skb *serr; 237 struct sock_exterr_skb *serr;
@@ -257,7 +250,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
257 skb_put(skb, sizeof(struct ipv6hdr)); 250 skb_put(skb, sizeof(struct ipv6hdr));
258 skb_reset_network_header(skb); 251 skb_reset_network_header(skb);
259 iph = ipv6_hdr(skb); 252 iph = ipv6_hdr(skb);
260 ipv6_addr_copy(&iph->daddr, &fl->fl6_dst); 253 ipv6_addr_copy(&iph->daddr, &fl6->daddr);
261 254
262 serr = SKB_EXT_ERR(skb); 255 serr = SKB_EXT_ERR(skb);
263 serr->ee.ee_errno = err; 256 serr->ee.ee_errno = err;
@@ -268,7 +261,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
268 serr->ee.ee_info = info; 261 serr->ee.ee_info = info;
269 serr->ee.ee_data = 0; 262 serr->ee.ee_data = 0;
270 serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb); 263 serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb);
271 serr->port = fl->fl_ip_dport; 264 serr->port = fl6->fl6_dport;
272 265
273 __skb_pull(skb, skb_tail_pointer(skb) - skb->data); 266 __skb_pull(skb, skb_tail_pointer(skb) - skb->data);
274 skb_reset_transport_header(skb); 267 skb_reset_transport_header(skb);
@@ -277,7 +270,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
277 kfree_skb(skb); 270 kfree_skb(skb);
278} 271}
279 272
280void ipv6_local_rxpmtu(struct sock *sk, struct flowi *fl, u32 mtu) 273void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu)
281{ 274{
282 struct ipv6_pinfo *np = inet6_sk(sk); 275 struct ipv6_pinfo *np = inet6_sk(sk);
283 struct ipv6hdr *iph; 276 struct ipv6hdr *iph;
@@ -294,7 +287,7 @@ void ipv6_local_rxpmtu(struct sock *sk, struct flowi *fl, u32 mtu)
294 skb_put(skb, sizeof(struct ipv6hdr)); 287 skb_put(skb, sizeof(struct ipv6hdr));
295 skb_reset_network_header(skb); 288 skb_reset_network_header(skb);
296 iph = ipv6_hdr(skb); 289 iph = ipv6_hdr(skb);
297 ipv6_addr_copy(&iph->daddr, &fl->fl6_dst); 290 ipv6_addr_copy(&iph->daddr, &fl6->daddr);
298 291
299 mtu_info = IP6CBMTU(skb); 292 mtu_info = IP6CBMTU(skb);
300 if (!mtu_info) { 293 if (!mtu_info) {
@@ -306,7 +299,7 @@ void ipv6_local_rxpmtu(struct sock *sk, struct flowi *fl, u32 mtu)
306 mtu_info->ip6m_addr.sin6_family = AF_INET6; 299 mtu_info->ip6m_addr.sin6_family = AF_INET6;
307 mtu_info->ip6m_addr.sin6_port = 0; 300 mtu_info->ip6m_addr.sin6_port = 0;
308 mtu_info->ip6m_addr.sin6_flowinfo = 0; 301 mtu_info->ip6m_addr.sin6_flowinfo = 0;
309 mtu_info->ip6m_addr.sin6_scope_id = fl->oif; 302 mtu_info->ip6m_addr.sin6_scope_id = fl6->flowi6_oif;
310 ipv6_addr_copy(&mtu_info->ip6m_addr.sin6_addr, &ipv6_hdr(skb)->daddr); 303 ipv6_addr_copy(&mtu_info->ip6m_addr.sin6_addr, &ipv6_hdr(skb)->daddr);
311 304
312 __skb_pull(skb, skb_tail_pointer(skb) - skb->data); 305 __skb_pull(skb, skb_tail_pointer(skb) - skb->data);
@@ -600,7 +593,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
600} 593}
601 594
602int datagram_send_ctl(struct net *net, 595int datagram_send_ctl(struct net *net,
603 struct msghdr *msg, struct flowi *fl, 596 struct msghdr *msg, struct flowi6 *fl6,
604 struct ipv6_txoptions *opt, 597 struct ipv6_txoptions *opt,
605 int *hlimit, int *tclass, int *dontfrag) 598 int *hlimit, int *tclass, int *dontfrag)
606{ 599{
@@ -636,16 +629,17 @@ int datagram_send_ctl(struct net *net,
636 src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg); 629 src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);
637 630
638 if (src_info->ipi6_ifindex) { 631 if (src_info->ipi6_ifindex) {
639 if (fl->oif && src_info->ipi6_ifindex != fl->oif) 632 if (fl6->flowi6_oif &&
633 src_info->ipi6_ifindex != fl6->flowi6_oif)
640 return -EINVAL; 634 return -EINVAL;
641 fl->oif = src_info->ipi6_ifindex; 635 fl6->flowi6_oif = src_info->ipi6_ifindex;
642 } 636 }
643 637
644 addr_type = __ipv6_addr_type(&src_info->ipi6_addr); 638 addr_type = __ipv6_addr_type(&src_info->ipi6_addr);
645 639
646 rcu_read_lock(); 640 rcu_read_lock();
647 if (fl->oif) { 641 if (fl6->flowi6_oif) {
648 dev = dev_get_by_index_rcu(net, fl->oif); 642 dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
649 if (!dev) { 643 if (!dev) {
650 rcu_read_unlock(); 644 rcu_read_unlock();
651 return -ENODEV; 645 return -ENODEV;
@@ -661,7 +655,7 @@ int datagram_send_ctl(struct net *net,
661 strict ? dev : NULL, 0)) 655 strict ? dev : NULL, 0))
662 err = -EINVAL; 656 err = -EINVAL;
663 else 657 else
664 ipv6_addr_copy(&fl->fl6_src, &src_info->ipi6_addr); 658 ipv6_addr_copy(&fl6->saddr, &src_info->ipi6_addr);
665 } 659 }
666 660
667 rcu_read_unlock(); 661 rcu_read_unlock();
@@ -678,13 +672,13 @@ int datagram_send_ctl(struct net *net,
678 goto exit_f; 672 goto exit_f;
679 } 673 }
680 674
681 if (fl->fl6_flowlabel&IPV6_FLOWINFO_MASK) { 675 if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
682 if ((fl->fl6_flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) { 676 if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
683 err = -EINVAL; 677 err = -EINVAL;
684 goto exit_f; 678 goto exit_f;
685 } 679 }
686 } 680 }
687 fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg); 681 fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
688 break; 682 break;
689 683
690 case IPV6_2292HOPOPTS: 684 case IPV6_2292HOPOPTS:
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 1b5c9825743b..59dccfbb5b11 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -54,16 +54,20 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu);
54/* 54/*
55 * 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.
56 * 56 *
57 * For alignment considerations the IV is placed at the front, followed 57 * For alignment considerations the upper 32 bits of the sequence number are
58 * by the request and finally the SG list. 58 * placed at the front, if present. Followed by the IV, the request and finally
59 * the SG list.
59 * 60 *
60 * TODO: Use spare space in skb for this where possible. 61 * TODO: Use spare space in skb for this where possible.
61 */ 62 */
62static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags) 63static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqihlen)
63{ 64{
64 unsigned int len; 65 unsigned int len;
65 66
66 len = crypto_aead_ivsize(aead); 67 len = seqihlen;
68
69 len += crypto_aead_ivsize(aead);
70
67 if (len) { 71 if (len) {
68 len += crypto_aead_alignmask(aead) & 72 len += crypto_aead_alignmask(aead) &
69 ~(crypto_tfm_ctx_alignment() - 1); 73 ~(crypto_tfm_ctx_alignment() - 1);
@@ -78,10 +82,16 @@ static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags)
78 return kmalloc(len, GFP_ATOMIC); 82 return kmalloc(len, GFP_ATOMIC);
79} 83}
80 84
81static inline u8 *esp_tmp_iv(struct crypto_aead *aead, void *tmp) 85static inline __be32 *esp_tmp_seqhi(void *tmp)
86{
87 return PTR_ALIGN((__be32 *)tmp, __alignof__(__be32));
88}
89
90static inline u8 *esp_tmp_iv(struct crypto_aead *aead, void *tmp, int seqhilen)
82{ 91{
83 return crypto_aead_ivsize(aead) ? 92 return crypto_aead_ivsize(aead) ?
84 PTR_ALIGN((u8 *)tmp, crypto_aead_alignmask(aead) + 1) : tmp; 93 PTR_ALIGN((u8 *)tmp + seqhilen,
94 crypto_aead_alignmask(aead) + 1) : tmp + seqhilen;
85} 95}
86 96
87static inline struct aead_givcrypt_request *esp_tmp_givreq( 97static inline struct aead_givcrypt_request *esp_tmp_givreq(
@@ -145,8 +155,12 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
145 int plen; 155 int plen;
146 int tfclen; 156 int tfclen;
147 int nfrags; 157 int nfrags;
158 int assoclen;
159 int sglists;
160 int seqhilen;
148 u8 *iv; 161 u8 *iv;
149 u8 *tail; 162 u8 *tail;
163 __be32 *seqhi;
150 struct esp_data *esp = x->data; 164 struct esp_data *esp = x->data;
151 165
152 /* skb is pure payload to encrypt */ 166 /* skb is pure payload to encrypt */
@@ -175,14 +189,25 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
175 goto error; 189 goto error;
176 nfrags = err; 190 nfrags = err;
177 191
178 tmp = esp_alloc_tmp(aead, nfrags + 1); 192 assoclen = sizeof(*esph);
193 sglists = 1;
194 seqhilen = 0;
195
196 if (x->props.flags & XFRM_STATE_ESN) {
197 sglists += 2;
198 seqhilen += sizeof(__be32);
199 assoclen += seqhilen;
200 }
201
202 tmp = esp_alloc_tmp(aead, nfrags + sglists, seqhilen);
179 if (!tmp) 203 if (!tmp)
180 goto error; 204 goto error;
181 205
182 iv = esp_tmp_iv(aead, tmp); 206 seqhi = esp_tmp_seqhi(tmp);
207 iv = esp_tmp_iv(aead, tmp, seqhilen);
183 req = esp_tmp_givreq(aead, iv); 208 req = esp_tmp_givreq(aead, iv);
184 asg = esp_givreq_sg(aead, req); 209 asg = esp_givreq_sg(aead, req);
185 sg = asg + 1; 210 sg = asg + sglists;
186 211
187 /* Fill padding... */ 212 /* Fill padding... */
188 tail = skb_tail_pointer(trailer); 213 tail = skb_tail_pointer(trailer);
@@ -204,19 +229,27 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
204 *skb_mac_header(skb) = IPPROTO_ESP; 229 *skb_mac_header(skb) = IPPROTO_ESP;
205 230
206 esph->spi = x->id.spi; 231 esph->spi = x->id.spi;
207 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output); 232 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);
208 233
209 sg_init_table(sg, nfrags); 234 sg_init_table(sg, nfrags);
210 skb_to_sgvec(skb, sg, 235 skb_to_sgvec(skb, sg,
211 esph->enc_data + crypto_aead_ivsize(aead) - skb->data, 236 esph->enc_data + crypto_aead_ivsize(aead) - skb->data,
212 clen + alen); 237 clen + alen);
213 sg_init_one(asg, esph, sizeof(*esph)); 238
239 if ((x->props.flags & XFRM_STATE_ESN)) {
240 sg_init_table(asg, 3);
241 sg_set_buf(asg, &esph->spi, sizeof(__be32));
242 *seqhi = htonl(XFRM_SKB_CB(skb)->seq.output.hi);
243 sg_set_buf(asg + 1, seqhi, seqhilen);
244 sg_set_buf(asg + 2, &esph->seq_no, sizeof(__be32));
245 } else
246 sg_init_one(asg, esph, sizeof(*esph));
214 247
215 aead_givcrypt_set_callback(req, 0, esp_output_done, skb); 248 aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
216 aead_givcrypt_set_crypt(req, sg, sg, clen, iv); 249 aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
217 aead_givcrypt_set_assoc(req, asg, sizeof(*esph)); 250 aead_givcrypt_set_assoc(req, asg, assoclen);
218 aead_givcrypt_set_giv(req, esph->enc_data, 251 aead_givcrypt_set_giv(req, esph->enc_data,
219 XFRM_SKB_CB(skb)->seq.output); 252 XFRM_SKB_CB(skb)->seq.output.low);
220 253
221 ESP_SKB_CB(skb)->tmp = tmp; 254 ESP_SKB_CB(skb)->tmp = tmp;
222 err = crypto_aead_givencrypt(req); 255 err = crypto_aead_givencrypt(req);
@@ -292,8 +325,12 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
292 struct sk_buff *trailer; 325 struct sk_buff *trailer;
293 int elen = skb->len - sizeof(*esph) - crypto_aead_ivsize(aead); 326 int elen = skb->len - sizeof(*esph) - crypto_aead_ivsize(aead);
294 int nfrags; 327 int nfrags;
328 int assoclen;
329 int sglists;
330 int seqhilen;
295 int ret = 0; 331 int ret = 0;
296 void *tmp; 332 void *tmp;
333 __be32 *seqhi;
297 u8 *iv; 334 u8 *iv;
298 struct scatterlist *sg; 335 struct scatterlist *sg;
299 struct scatterlist *asg; 336 struct scatterlist *asg;
@@ -314,15 +351,27 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
314 } 351 }
315 352
316 ret = -ENOMEM; 353 ret = -ENOMEM;
317 tmp = esp_alloc_tmp(aead, nfrags + 1); 354
355 assoclen = sizeof(*esph);
356 sglists = 1;
357 seqhilen = 0;
358
359 if (x->props.flags & XFRM_STATE_ESN) {
360 sglists += 2;
361 seqhilen += sizeof(__be32);
362 assoclen += seqhilen;
363 }
364
365 tmp = esp_alloc_tmp(aead, nfrags + sglists, seqhilen);
318 if (!tmp) 366 if (!tmp)
319 goto out; 367 goto out;
320 368
321 ESP_SKB_CB(skb)->tmp = tmp; 369 ESP_SKB_CB(skb)->tmp = tmp;
322 iv = esp_tmp_iv(aead, tmp); 370 seqhi = esp_tmp_seqhi(tmp);
371 iv = esp_tmp_iv(aead, tmp, seqhilen);
323 req = esp_tmp_req(aead, iv); 372 req = esp_tmp_req(aead, iv);
324 asg = esp_req_sg(aead, req); 373 asg = esp_req_sg(aead, req);
325 sg = asg + 1; 374 sg = asg + sglists;
326 375
327 skb->ip_summed = CHECKSUM_NONE; 376 skb->ip_summed = CHECKSUM_NONE;
328 377
@@ -333,11 +382,19 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
333 382
334 sg_init_table(sg, nfrags); 383 sg_init_table(sg, nfrags);
335 skb_to_sgvec(skb, sg, sizeof(*esph) + crypto_aead_ivsize(aead), elen); 384 skb_to_sgvec(skb, sg, sizeof(*esph) + crypto_aead_ivsize(aead), elen);
336 sg_init_one(asg, esph, sizeof(*esph)); 385
386 if ((x->props.flags & XFRM_STATE_ESN)) {
387 sg_init_table(asg, 3);
388 sg_set_buf(asg, &esph->spi, sizeof(__be32));
389 *seqhi = XFRM_SKB_CB(skb)->seq.input.hi;
390 sg_set_buf(asg + 1, seqhi, seqhilen);
391 sg_set_buf(asg + 2, &esph->seq_no, sizeof(__be32));
392 } else
393 sg_init_one(asg, esph, sizeof(*esph));
337 394
338 aead_request_set_callback(req, 0, esp_input_done, skb); 395 aead_request_set_callback(req, 0, esp_input_done, skb);
339 aead_request_set_crypt(req, sg, sg, elen, iv); 396 aead_request_set_crypt(req, sg, sg, elen, iv);
340 aead_request_set_assoc(req, asg, sizeof(*esph)); 397 aead_request_set_assoc(req, asg, assoclen);
341 398
342 ret = crypto_aead_decrypt(req); 399 ret = crypto_aead_decrypt(req);
343 if (ret == -EINPROGRESS) 400 if (ret == -EINPROGRESS)
@@ -443,10 +500,20 @@ static int esp_init_authenc(struct xfrm_state *x)
443 goto error; 500 goto error;
444 501
445 err = -ENAMETOOLONG; 502 err = -ENAMETOOLONG;
446 if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME, "authenc(%s,%s)", 503
447 x->aalg ? x->aalg->alg_name : "digest_null", 504 if ((x->props.flags & XFRM_STATE_ESN)) {
448 x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME) 505 if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,
449 goto error; 506 "authencesn(%s,%s)",
507 x->aalg ? x->aalg->alg_name : "digest_null",
508 x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
509 goto error;
510 } else {
511 if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,
512 "authenc(%s,%s)",
513 x->aalg ? x->aalg->alg_name : "digest_null",
514 x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
515 goto error;
516 }
450 517
451 aead = crypto_alloc_aead(authenc_name, 0, 0); 518 aead = crypto_alloc_aead(authenc_name, 0, 0);
452 err = PTR_ERR(aead); 519 err = PTR_ERR(aead);
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 262f105d23b9..79a485e8a700 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -876,22 +876,22 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
876 * fl6_update_dst - update flowi destination address with info given 876 * fl6_update_dst - update flowi destination address with info given
877 * by srcrt option, if any. 877 * by srcrt option, if any.
878 * 878 *
879 * @fl: flowi for which fl6_dst is to be updated 879 * @fl6: flowi6 for which daddr is to be updated
880 * @opt: struct ipv6_txoptions in which to look for srcrt opt 880 * @opt: struct ipv6_txoptions in which to look for srcrt opt
881 * @orig: copy of original fl6_dst address if modified 881 * @orig: copy of original daddr address if modified
882 * 882 *
883 * Returns NULL if no txoptions or no srcrt, otherwise returns orig 883 * Returns NULL if no txoptions or no srcrt, otherwise returns orig
884 * and initial value of fl->fl6_dst set in orig 884 * and initial value of fl6->daddr set in orig
885 */ 885 */
886struct in6_addr *fl6_update_dst(struct flowi *fl, 886struct in6_addr *fl6_update_dst(struct flowi6 *fl6,
887 const struct ipv6_txoptions *opt, 887 const struct ipv6_txoptions *opt,
888 struct in6_addr *orig) 888 struct in6_addr *orig)
889{ 889{
890 if (!opt || !opt->srcrt) 890 if (!opt || !opt->srcrt)
891 return NULL; 891 return NULL;
892 892
893 ipv6_addr_copy(orig, &fl->fl6_dst); 893 ipv6_addr_copy(orig, &fl6->daddr);
894 ipv6_addr_copy(&fl->fl6_dst, ((struct rt0_hdr *)opt->srcrt)->addr); 894 ipv6_addr_copy(&fl6->daddr, ((struct rt0_hdr *)opt->srcrt)->addr);
895 return orig; 895 return orig;
896} 896}
897 897
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index d829874d8946..34d244df907d 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -29,7 +29,7 @@ struct fib6_rule
29 u8 tclass; 29 u8 tclass;
30}; 30};
31 31
32struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl, 32struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
33 int flags, pol_lookup_t lookup) 33 int flags, pol_lookup_t lookup)
34{ 34{
35 struct fib_lookup_arg arg = { 35 struct fib_lookup_arg arg = {
@@ -37,7 +37,8 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl,
37 .flags = FIB_LOOKUP_NOREF, 37 .flags = FIB_LOOKUP_NOREF,
38 }; 38 };
39 39
40 fib_rules_lookup(net->ipv6.fib6_rules_ops, fl, flags, &arg); 40 fib_rules_lookup(net->ipv6.fib6_rules_ops,
41 flowi6_to_flowi(fl6), flags, &arg);
41 42
42 if (arg.result) 43 if (arg.result)
43 return arg.result; 44 return arg.result;
@@ -49,6 +50,7 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl,
49static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, 50static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
50 int flags, struct fib_lookup_arg *arg) 51 int flags, struct fib_lookup_arg *arg)
51{ 52{
53 struct flowi6 *flp6 = &flp->u.ip6;
52 struct rt6_info *rt = NULL; 54 struct rt6_info *rt = NULL;
53 struct fib6_table *table; 55 struct fib6_table *table;
54 struct net *net = rule->fr_net; 56 struct net *net = rule->fr_net;
@@ -71,7 +73,7 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
71 73
72 table = fib6_get_table(net, rule->table); 74 table = fib6_get_table(net, rule->table);
73 if (table) 75 if (table)
74 rt = lookup(net, table, flp, flags); 76 rt = lookup(net, table, flp6, flags);
75 77
76 if (rt != net->ipv6.ip6_null_entry) { 78 if (rt != net->ipv6.ip6_null_entry) {
77 struct fib6_rule *r = (struct fib6_rule *)rule; 79 struct fib6_rule *r = (struct fib6_rule *)rule;
@@ -86,14 +88,14 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
86 88
87 if (ipv6_dev_get_saddr(net, 89 if (ipv6_dev_get_saddr(net,
88 ip6_dst_idev(&rt->dst)->dev, 90 ip6_dst_idev(&rt->dst)->dev,
89 &flp->fl6_dst, 91 &flp6->daddr,
90 rt6_flags2srcprefs(flags), 92 rt6_flags2srcprefs(flags),
91 &saddr)) 93 &saddr))
92 goto again; 94 goto again;
93 if (!ipv6_prefix_equal(&saddr, &r->src.addr, 95 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
94 r->src.plen)) 96 r->src.plen))
95 goto again; 97 goto again;
96 ipv6_addr_copy(&flp->fl6_src, &saddr); 98 ipv6_addr_copy(&flp6->saddr, &saddr);
97 } 99 }
98 goto out; 100 goto out;
99 } 101 }
@@ -113,9 +115,10 @@ out:
113static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) 115static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
114{ 116{
115 struct fib6_rule *r = (struct fib6_rule *) rule; 117 struct fib6_rule *r = (struct fib6_rule *) rule;
118 struct flowi6 *fl6 = &fl->u.ip6;
116 119
117 if (r->dst.plen && 120 if (r->dst.plen &&
118 !ipv6_prefix_equal(&fl->fl6_dst, &r->dst.addr, r->dst.plen)) 121 !ipv6_prefix_equal(&fl6->daddr, &r->dst.addr, r->dst.plen))
119 return 0; 122 return 0;
120 123
121 /* 124 /*
@@ -125,14 +128,14 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
125 */ 128 */
126 if (r->src.plen) { 129 if (r->src.plen) {
127 if (flags & RT6_LOOKUP_F_HAS_SADDR) { 130 if (flags & RT6_LOOKUP_F_HAS_SADDR) {
128 if (!ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, 131 if (!ipv6_prefix_equal(&fl6->saddr, &r->src.addr,
129 r->src.plen)) 132 r->src.plen))
130 return 0; 133 return 0;
131 } else if (!(r->common.flags & FIB_RULE_FIND_SADDR)) 134 } else if (!(r->common.flags & FIB_RULE_FIND_SADDR))
132 return 0; 135 return 0;
133 } 136 }
134 137
135 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff)) 138 if (r->tclass && r->tclass != ((ntohl(fl6->flowlabel) >> 20) & 0xff))
136 return 0; 139 return 0;
137 140
138 return 1; 141 return 1;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 03e62f94ff8e..83cb4f9add81 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -157,32 +157,32 @@ static int is_ineligible(struct sk_buff *skb)
157/* 157/*
158 * Check the ICMP output rate limit 158 * Check the ICMP output rate limit
159 */ 159 */
160static inline int icmpv6_xrlim_allow(struct sock *sk, u8 type, 160static inline bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
161 struct flowi *fl) 161 struct flowi6 *fl6)
162{ 162{
163 struct dst_entry *dst; 163 struct dst_entry *dst;
164 struct net *net = sock_net(sk); 164 struct net *net = sock_net(sk);
165 int res = 0; 165 bool res = false;
166 166
167 /* Informational messages are not limited. */ 167 /* Informational messages are not limited. */
168 if (type & ICMPV6_INFOMSG_MASK) 168 if (type & ICMPV6_INFOMSG_MASK)
169 return 1; 169 return true;
170 170
171 /* Do not limit pmtu discovery, it would break it. */ 171 /* Do not limit pmtu discovery, it would break it. */
172 if (type == ICMPV6_PKT_TOOBIG) 172 if (type == ICMPV6_PKT_TOOBIG)
173 return 1; 173 return true;
174 174
175 /* 175 /*
176 * Look up the output route. 176 * Look up the output route.
177 * XXX: perhaps the expire for routing entries cloned by 177 * XXX: perhaps the expire for routing entries cloned by
178 * this lookup should be more aggressive (not longer than timeout). 178 * this lookup should be more aggressive (not longer than timeout).
179 */ 179 */
180 dst = ip6_route_output(net, sk, fl); 180 dst = ip6_route_output(net, sk, fl6);
181 if (dst->error) { 181 if (dst->error) {
182 IP6_INC_STATS(net, ip6_dst_idev(dst), 182 IP6_INC_STATS(net, ip6_dst_idev(dst),
183 IPSTATS_MIB_OUTNOROUTES); 183 IPSTATS_MIB_OUTNOROUTES);
184 } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) { 184 } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) {
185 res = 1; 185 res = true;
186 } else { 186 } else {
187 struct rt6_info *rt = (struct rt6_info *)dst; 187 struct rt6_info *rt = (struct rt6_info *)dst;
188 int tmo = net->ipv6.sysctl.icmpv6_time; 188 int tmo = net->ipv6.sysctl.icmpv6_time;
@@ -191,7 +191,9 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, u8 type,
191 if (rt->rt6i_dst.plen < 128) 191 if (rt->rt6i_dst.plen < 128)
192 tmo >>= ((128 - rt->rt6i_dst.plen)>>5); 192 tmo >>= ((128 - rt->rt6i_dst.plen)>>5);
193 193
194 res = xrlim_allow(dst, tmo); 194 if (!rt->rt6i_peer)
195 rt6_bind_peer(rt, 1);
196 res = inet_peer_xrlim_allow(rt->rt6i_peer, tmo);
195 } 197 }
196 dst_release(dst); 198 dst_release(dst);
197 return res; 199 return res;
@@ -215,7 +217,7 @@ static __inline__ int opt_unrec(struct sk_buff *skb, __u32 offset)
215 return (*op & 0xC0) == 0x80; 217 return (*op & 0xC0) == 0x80;
216} 218}
217 219
218static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct icmp6hdr *thdr, int len) 220static int icmpv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6, struct icmp6hdr *thdr, int len)
219{ 221{
220 struct sk_buff *skb; 222 struct sk_buff *skb;
221 struct icmp6hdr *icmp6h; 223 struct icmp6hdr *icmp6h;
@@ -231,9 +233,9 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
231 if (skb_queue_len(&sk->sk_write_queue) == 1) { 233 if (skb_queue_len(&sk->sk_write_queue) == 1) {
232 skb->csum = csum_partial(icmp6h, 234 skb->csum = csum_partial(icmp6h,
233 sizeof(struct icmp6hdr), skb->csum); 235 sizeof(struct icmp6hdr), skb->csum);
234 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src, 236 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl6->saddr,
235 &fl->fl6_dst, 237 &fl6->daddr,
236 len, fl->proto, 238 len, fl6->flowi6_proto,
237 skb->csum); 239 skb->csum);
238 } else { 240 } else {
239 __wsum tmp_csum = 0; 241 __wsum tmp_csum = 0;
@@ -244,9 +246,9 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
244 246
245 tmp_csum = csum_partial(icmp6h, 247 tmp_csum = csum_partial(icmp6h,
246 sizeof(struct icmp6hdr), tmp_csum); 248 sizeof(struct icmp6hdr), tmp_csum);
247 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src, 249 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl6->saddr,
248 &fl->fl6_dst, 250 &fl6->daddr,
249 len, fl->proto, 251 len, fl6->flowi6_proto,
250 tmp_csum); 252 tmp_csum);
251 } 253 }
252 ip6_push_pending_frames(sk); 254 ip6_push_pending_frames(sk);
@@ -298,6 +300,68 @@ static void mip6_addr_swap(struct sk_buff *skb)
298static inline void mip6_addr_swap(struct sk_buff *skb) {} 300static inline void mip6_addr_swap(struct sk_buff *skb) {}
299#endif 301#endif
300 302
303static struct dst_entry *icmpv6_route_lookup(struct net *net, struct sk_buff *skb,
304 struct sock *sk, struct flowi6 *fl6)
305{
306 struct dst_entry *dst, *dst2;
307 struct flowi6 fl2;
308 int err;
309
310 err = ip6_dst_lookup(sk, &dst, fl6);
311 if (err)
312 return ERR_PTR(err);
313
314 /*
315 * We won't send icmp if the destination is known
316 * anycast.
317 */
318 if (((struct rt6_info *)dst)->rt6i_flags & RTF_ANYCAST) {
319 LIMIT_NETDEBUG(KERN_DEBUG "icmpv6_send: acast source\n");
320 dst_release(dst);
321 return ERR_PTR(-EINVAL);
322 }
323
324 /* No need to clone since we're just using its address. */
325 dst2 = dst;
326
327 dst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), sk, 0);
328 if (!IS_ERR(dst)) {
329 if (dst != dst2)
330 return dst;
331 } else {
332 if (PTR_ERR(dst) == -EPERM)
333 dst = NULL;
334 else
335 return dst;
336 }
337
338 err = xfrm_decode_session_reverse(skb, flowi6_to_flowi(&fl2), AF_INET6);
339 if (err)
340 goto relookup_failed;
341
342 err = ip6_dst_lookup(sk, &dst2, &fl2);
343 if (err)
344 goto relookup_failed;
345
346 dst2 = xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk, XFRM_LOOKUP_ICMP);
347 if (!IS_ERR(dst2)) {
348 dst_release(dst);
349 dst = dst2;
350 } else {
351 err = PTR_ERR(dst2);
352 if (err == -EPERM) {
353 dst_release(dst);
354 return dst2;
355 } else
356 goto relookup_failed;
357 }
358
359relookup_failed:
360 if (dst)
361 return dst;
362 return ERR_PTR(err);
363}
364
301/* 365/*
302 * Send an ICMP message in response to a packet in error 366 * Send an ICMP message in response to a packet in error
303 */ 367 */
@@ -310,10 +374,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
310 struct ipv6_pinfo *np; 374 struct ipv6_pinfo *np;
311 struct in6_addr *saddr = NULL; 375 struct in6_addr *saddr = NULL;
312 struct dst_entry *dst; 376 struct dst_entry *dst;
313 struct dst_entry *dst2;
314 struct icmp6hdr tmp_hdr; 377 struct icmp6hdr tmp_hdr;
315 struct flowi fl; 378 struct flowi6 fl6;
316 struct flowi fl2;
317 struct icmpv6_msg msg; 379 struct icmpv6_msg msg;
318 int iif = 0; 380 int iif = 0;
319 int addr_type = 0; 381 int addr_type = 0;
@@ -380,22 +442,22 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
380 442
381 mip6_addr_swap(skb); 443 mip6_addr_swap(skb);
382 444
383 memset(&fl, 0, sizeof(fl)); 445 memset(&fl6, 0, sizeof(fl6));
384 fl.proto = IPPROTO_ICMPV6; 446 fl6.flowi6_proto = IPPROTO_ICMPV6;
385 ipv6_addr_copy(&fl.fl6_dst, &hdr->saddr); 447 ipv6_addr_copy(&fl6.daddr, &hdr->saddr);
386 if (saddr) 448 if (saddr)
387 ipv6_addr_copy(&fl.fl6_src, saddr); 449 ipv6_addr_copy(&fl6.saddr, saddr);
388 fl.oif = iif; 450 fl6.flowi6_oif = iif;
389 fl.fl_icmp_type = type; 451 fl6.fl6_icmp_type = type;
390 fl.fl_icmp_code = code; 452 fl6.fl6_icmp_code = code;
391 security_skb_classify_flow(skb, &fl); 453 security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));
392 454
393 sk = icmpv6_xmit_lock(net); 455 sk = icmpv6_xmit_lock(net);
394 if (sk == NULL) 456 if (sk == NULL)
395 return; 457 return;
396 np = inet6_sk(sk); 458 np = inet6_sk(sk);
397 459
398 if (!icmpv6_xrlim_allow(sk, type, &fl)) 460 if (!icmpv6_xrlim_allow(sk, type, &fl6))
399 goto out; 461 goto out;
400 462
401 tmp_hdr.icmp6_type = type; 463 tmp_hdr.icmp6_type = type;
@@ -403,61 +465,14 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
403 tmp_hdr.icmp6_cksum = 0; 465 tmp_hdr.icmp6_cksum = 0;
404 tmp_hdr.icmp6_pointer = htonl(info); 466 tmp_hdr.icmp6_pointer = htonl(info);
405 467
406 if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) 468 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
407 fl.oif = np->mcast_oif; 469 fl6.flowi6_oif = np->mcast_oif;
408 470
409 err = ip6_dst_lookup(sk, &dst, &fl); 471 dst = icmpv6_route_lookup(net, skb, sk, &fl6);
410 if (err) 472 if (IS_ERR(dst))
411 goto out; 473 goto out;
412 474
413 /* 475 if (ipv6_addr_is_multicast(&fl6.daddr))
414 * We won't send icmp if the destination is known
415 * anycast.
416 */
417 if (((struct rt6_info *)dst)->rt6i_flags & RTF_ANYCAST) {
418 LIMIT_NETDEBUG(KERN_DEBUG "icmpv6_send: acast source\n");
419 goto out_dst_release;
420 }
421
422 /* No need to clone since we're just using its address. */
423 dst2 = dst;
424
425 err = xfrm_lookup(net, &dst, &fl, sk, 0);
426 switch (err) {
427 case 0:
428 if (dst != dst2)
429 goto route_done;
430 break;
431 case -EPERM:
432 dst = NULL;
433 break;
434 default:
435 goto out;
436 }
437
438 if (xfrm_decode_session_reverse(skb, &fl2, AF_INET6))
439 goto relookup_failed;
440
441 if (ip6_dst_lookup(sk, &dst2, &fl2))
442 goto relookup_failed;
443
444 err = xfrm_lookup(net, &dst2, &fl2, sk, XFRM_LOOKUP_ICMP);
445 switch (err) {
446 case 0:
447 dst_release(dst);
448 dst = dst2;
449 break;
450 case -EPERM:
451 goto out_dst_release;
452 default:
453relookup_failed:
454 if (!dst)
455 goto out;
456 break;
457 }
458
459route_done:
460 if (ipv6_addr_is_multicast(&fl.fl6_dst))
461 hlimit = np->mcast_hops; 476 hlimit = np->mcast_hops;
462 else 477 else
463 hlimit = np->hop_limit; 478 hlimit = np->hop_limit;
@@ -480,14 +495,14 @@ route_done:
480 err = ip6_append_data(sk, icmpv6_getfrag, &msg, 495 err = ip6_append_data(sk, icmpv6_getfrag, &msg,
481 len + sizeof(struct icmp6hdr), 496 len + sizeof(struct icmp6hdr),
482 sizeof(struct icmp6hdr), hlimit, 497 sizeof(struct icmp6hdr), hlimit,
483 np->tclass, NULL, &fl, (struct rt6_info*)dst, 498 np->tclass, NULL, &fl6, (struct rt6_info*)dst,
484 MSG_DONTWAIT, np->dontfrag); 499 MSG_DONTWAIT, np->dontfrag);
485 if (err) { 500 if (err) {
486 ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTERRORS); 501 ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTERRORS);
487 ip6_flush_pending_frames(sk); 502 ip6_flush_pending_frames(sk);
488 goto out_put; 503 goto out_put;
489 } 504 }
490 err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, len + sizeof(struct icmp6hdr)); 505 err = icmpv6_push_pending_frames(sk, &fl6, &tmp_hdr, len + sizeof(struct icmp6hdr));
491 506
492out_put: 507out_put:
493 if (likely(idev != NULL)) 508 if (likely(idev != NULL))
@@ -509,7 +524,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
509 struct in6_addr *saddr = NULL; 524 struct in6_addr *saddr = NULL;
510 struct icmp6hdr *icmph = icmp6_hdr(skb); 525 struct icmp6hdr *icmph = icmp6_hdr(skb);
511 struct icmp6hdr tmp_hdr; 526 struct icmp6hdr tmp_hdr;
512 struct flowi fl; 527 struct flowi6 fl6;
513 struct icmpv6_msg msg; 528 struct icmpv6_msg msg;
514 struct dst_entry *dst; 529 struct dst_entry *dst;
515 int err = 0; 530 int err = 0;
@@ -523,30 +538,31 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
523 memcpy(&tmp_hdr, icmph, sizeof(tmp_hdr)); 538 memcpy(&tmp_hdr, icmph, sizeof(tmp_hdr));
524 tmp_hdr.icmp6_type = ICMPV6_ECHO_REPLY; 539 tmp_hdr.icmp6_type = ICMPV6_ECHO_REPLY;
525 540
526 memset(&fl, 0, sizeof(fl)); 541 memset(&fl6, 0, sizeof(fl6));
527 fl.proto = IPPROTO_ICMPV6; 542 fl6.flowi6_proto = IPPROTO_ICMPV6;
528 ipv6_addr_copy(&fl.fl6_dst, &ipv6_hdr(skb)->saddr); 543 ipv6_addr_copy(&fl6.daddr, &ipv6_hdr(skb)->saddr);
529 if (saddr) 544 if (saddr)
530 ipv6_addr_copy(&fl.fl6_src, saddr); 545 ipv6_addr_copy(&fl6.saddr, saddr);
531 fl.oif = skb->dev->ifindex; 546 fl6.flowi6_oif = skb->dev->ifindex;
532 fl.fl_icmp_type = ICMPV6_ECHO_REPLY; 547 fl6.fl6_icmp_type = ICMPV6_ECHO_REPLY;
533 security_skb_classify_flow(skb, &fl); 548 security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));
534 549
535 sk = icmpv6_xmit_lock(net); 550 sk = icmpv6_xmit_lock(net);
536 if (sk == NULL) 551 if (sk == NULL)
537 return; 552 return;
538 np = inet6_sk(sk); 553 np = inet6_sk(sk);
539 554
540 if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) 555 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
541 fl.oif = np->mcast_oif; 556 fl6.flowi6_oif = np->mcast_oif;
542 557
543 err = ip6_dst_lookup(sk, &dst, &fl); 558 err = ip6_dst_lookup(sk, &dst, &fl6);
544 if (err) 559 if (err)
545 goto out; 560 goto out;
546 if ((err = xfrm_lookup(net, &dst, &fl, sk, 0)) < 0) 561 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), sk, 0);
562 if (IS_ERR(dst))
547 goto out; 563 goto out;
548 564
549 if (ipv6_addr_is_multicast(&fl.fl6_dst)) 565 if (ipv6_addr_is_multicast(&fl6.daddr))
550 hlimit = np->mcast_hops; 566 hlimit = np->mcast_hops;
551 else 567 else
552 hlimit = np->hop_limit; 568 hlimit = np->hop_limit;
@@ -560,7 +576,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
560 msg.type = ICMPV6_ECHO_REPLY; 576 msg.type = ICMPV6_ECHO_REPLY;
561 577
562 err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), 578 err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr),
563 sizeof(struct icmp6hdr), hlimit, np->tclass, NULL, &fl, 579 sizeof(struct icmp6hdr), hlimit, np->tclass, NULL, &fl6,
564 (struct rt6_info*)dst, MSG_DONTWAIT, 580 (struct rt6_info*)dst, MSG_DONTWAIT,
565 np->dontfrag); 581 np->dontfrag);
566 582
@@ -569,7 +585,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
569 ip6_flush_pending_frames(sk); 585 ip6_flush_pending_frames(sk);
570 goto out_put; 586 goto out_put;
571 } 587 }
572 err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr)); 588 err = icmpv6_push_pending_frames(sk, &fl6, &tmp_hdr, skb->len + sizeof(struct icmp6hdr));
573 589
574out_put: 590out_put:
575 if (likely(idev != NULL)) 591 if (likely(idev != NULL))
@@ -768,20 +784,20 @@ drop_no_count:
768 return 0; 784 return 0;
769} 785}
770 786
771void icmpv6_flow_init(struct sock *sk, struct flowi *fl, 787void icmpv6_flow_init(struct sock *sk, struct flowi6 *fl6,
772 u8 type, 788 u8 type,
773 const struct in6_addr *saddr, 789 const struct in6_addr *saddr,
774 const struct in6_addr *daddr, 790 const struct in6_addr *daddr,
775 int oif) 791 int oif)
776{ 792{
777 memset(fl, 0, sizeof(*fl)); 793 memset(fl6, 0, sizeof(*fl6));
778 ipv6_addr_copy(&fl->fl6_src, saddr); 794 ipv6_addr_copy(&fl6->saddr, saddr);
779 ipv6_addr_copy(&fl->fl6_dst, daddr); 795 ipv6_addr_copy(&fl6->daddr, daddr);
780 fl->proto = IPPROTO_ICMPV6; 796 fl6->flowi6_proto = IPPROTO_ICMPV6;
781 fl->fl_icmp_type = type; 797 fl6->fl6_icmp_type = type;
782 fl->fl_icmp_code = 0; 798 fl6->fl6_icmp_code = 0;
783 fl->oif = oif; 799 fl6->flowi6_oif = oif;
784 security_sk_classify_flow(sk, fl); 800 security_sk_classify_flow(sk, flowi6_to_flowi(fl6));
785} 801}
786 802
787/* 803/*
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index d144e629d2b4..f2c5b0fc0f21 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 ((1 << sk2->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))) && 47 sk2->sk_state == TCP_LISTEN) &&
48 ipv6_rcv_saddr_equal(sk, sk2)) 48 ipv6_rcv_saddr_equal(sk, sk2))
49 break; 49 break;
50 } 50 }
@@ -61,26 +61,21 @@ struct dst_entry *inet6_csk_route_req(struct sock *sk,
61 struct ipv6_pinfo *np = inet6_sk(sk); 61 struct ipv6_pinfo *np = inet6_sk(sk);
62 struct in6_addr *final_p, final; 62 struct in6_addr *final_p, final;
63 struct dst_entry *dst; 63 struct dst_entry *dst;
64 struct flowi fl; 64 struct flowi6 fl6;
65 65
66 memset(&fl, 0, sizeof(fl)); 66 memset(&fl6, 0, sizeof(fl6));
67 fl.proto = IPPROTO_TCP; 67 fl6.flowi6_proto = IPPROTO_TCP;
68 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); 68 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr);
69 final_p = fl6_update_dst(&fl, np->opt, &final); 69 final_p = fl6_update_dst(&fl6, np->opt, &final);
70 ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr); 70 ipv6_addr_copy(&fl6.saddr, &treq->loc_addr);
71 fl.oif = sk->sk_bound_dev_if; 71 fl6.flowi6_oif = sk->sk_bound_dev_if;
72 fl.mark = sk->sk_mark; 72 fl6.flowi6_mark = sk->sk_mark;
73 fl.fl_ip_dport = inet_rsk(req)->rmt_port; 73 fl6.fl6_dport = inet_rsk(req)->rmt_port;
74 fl.fl_ip_sport = inet_rsk(req)->loc_port; 74 fl6.fl6_sport = inet_rsk(req)->loc_port;
75 security_req_classify_flow(req, &fl); 75 security_req_classify_flow(req, flowi6_to_flowi(&fl6));
76 76
77 if (ip6_dst_lookup(sk, &dst, &fl)) 77 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
78 return NULL; 78 if (IS_ERR(dst))
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; 79 return NULL;
85 80
86 return dst; 81 return dst;
@@ -213,42 +208,34 @@ int inet6_csk_xmit(struct sk_buff *skb)
213 struct sock *sk = skb->sk; 208 struct sock *sk = skb->sk;
214 struct inet_sock *inet = inet_sk(sk); 209 struct inet_sock *inet = inet_sk(sk);
215 struct ipv6_pinfo *np = inet6_sk(sk); 210 struct ipv6_pinfo *np = inet6_sk(sk);
216 struct flowi fl; 211 struct flowi6 fl6;
217 struct dst_entry *dst; 212 struct dst_entry *dst;
218 struct in6_addr *final_p, final; 213 struct in6_addr *final_p, final;
219 214
220 memset(&fl, 0, sizeof(fl)); 215 memset(&fl6, 0, sizeof(fl6));
221 fl.proto = sk->sk_protocol; 216 fl6.flowi6_proto = sk->sk_protocol;
222 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 217 ipv6_addr_copy(&fl6.daddr, &np->daddr);
223 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 218 ipv6_addr_copy(&fl6.saddr, &np->saddr);
224 fl.fl6_flowlabel = np->flow_label; 219 fl6.flowlabel = np->flow_label;
225 IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel); 220 IP6_ECN_flow_xmit(sk, fl6.flowlabel);
226 fl.oif = sk->sk_bound_dev_if; 221 fl6.flowi6_oif = sk->sk_bound_dev_if;
227 fl.mark = sk->sk_mark; 222 fl6.flowi6_mark = sk->sk_mark;
228 fl.fl_ip_sport = inet->inet_sport; 223 fl6.fl6_sport = inet->inet_sport;
229 fl.fl_ip_dport = inet->inet_dport; 224 fl6.fl6_dport = inet->inet_dport;
230 security_sk_classify_flow(sk, &fl); 225 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
231 226
232 final_p = fl6_update_dst(&fl, np->opt, &final); 227 final_p = fl6_update_dst(&fl6, np->opt, &final);
233 228
234 dst = __inet6_csk_dst_check(sk, np->dst_cookie); 229 dst = __inet6_csk_dst_check(sk, np->dst_cookie);
235 230
236 if (dst == NULL) { 231 if (dst == NULL) {
237 int err = ip6_dst_lookup(sk, &dst, &fl); 232 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
238
239 if (err) {
240 sk->sk_err_soft = -err;
241 kfree_skb(skb);
242 return err;
243 }
244
245 if (final_p)
246 ipv6_addr_copy(&fl.fl6_dst, final_p);
247 233
248 if ((err = xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0) { 234 if (IS_ERR(dst)) {
235 sk->sk_err_soft = -PTR_ERR(dst);
249 sk->sk_route_caps = 0; 236 sk->sk_route_caps = 0;
250 kfree_skb(skb); 237 kfree_skb(skb);
251 return err; 238 return PTR_ERR(dst);
252 } 239 }
253 240
254 __inet6_csk_dst_store(sk, dst, NULL, NULL); 241 __inet6_csk_dst_store(sk, dst, NULL, NULL);
@@ -257,9 +244,9 @@ int inet6_csk_xmit(struct sk_buff *skb)
257 skb_dst_set(skb, dst_clone(dst)); 244 skb_dst_set(skb, dst_clone(dst));
258 245
259 /* Restore final destination back after routing done */ 246 /* Restore final destination back after routing done */
260 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 247 ipv6_addr_copy(&fl6.daddr, &np->daddr);
261 248
262 return ip6_xmit(sk, skb, &fl, np->opt); 249 return ip6_xmit(sk, skb, &fl6, np->opt);
263} 250}
264 251
265EXPORT_SYMBOL_GPL(inet6_csk_xmit); 252EXPORT_SYMBOL_GPL(inet6_csk_xmit);
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 633a6c266136..b53197233709 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -124,7 +124,7 @@ out:
124} 124}
125EXPORT_SYMBOL(__inet6_lookup_established); 125EXPORT_SYMBOL(__inet6_lookup_established);
126 126
127static int inline compute_score(struct sock *sk, struct net *net, 127static inline int compute_score(struct sock *sk, struct net *net,
128 const unsigned short hnum, 128 const unsigned short hnum,
129 const struct in6_addr *daddr, 129 const struct in6_addr *daddr,
130 const int dif) 130 const int dif)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index de382114609b..7548905e79e1 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -260,10 +260,10 @@ struct fib6_table *fib6_get_table(struct net *net, u32 id)
260 return net->ipv6.fib6_main_tbl; 260 return net->ipv6.fib6_main_tbl;
261} 261}
262 262
263struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl, 263struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
264 int flags, pol_lookup_t lookup) 264 int flags, pol_lookup_t lookup)
265{ 265{
266 return (struct dst_entry *) lookup(net, net->ipv6.fib6_main_tbl, fl, flags); 266 return (struct dst_entry *) lookup(net, net->ipv6.fib6_main_tbl, fl6, flags);
267} 267}
268 268
269static void __net_init fib6_tables_init(struct net *net) 269static void __net_init fib6_tables_init(struct net *net)
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 13654686aeab..f3caf1b8d572 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -342,7 +342,7 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
342 342
343 if (olen > 0) { 343 if (olen > 0) {
344 struct msghdr msg; 344 struct msghdr msg;
345 struct flowi flowi; 345 struct flowi6 flowi6;
346 int junk; 346 int junk;
347 347
348 err = -ENOMEM; 348 err = -ENOMEM;
@@ -358,9 +358,9 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
358 358
359 msg.msg_controllen = olen; 359 msg.msg_controllen = olen;
360 msg.msg_control = (void*)(fl->opt+1); 360 msg.msg_control = (void*)(fl->opt+1);
361 flowi.oif = 0; 361 memset(&flowi6, 0, sizeof(flowi6));
362 362
363 err = datagram_send_ctl(net, &msg, &flowi, fl->opt, &junk, 363 err = datagram_send_ctl(net, &msg, &flowi6, fl->opt, &junk,
364 &junk, &junk); 364 &junk, &junk);
365 if (err) 365 if (err)
366 goto done; 366 goto done;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 5f8d242be3f3..46cf7bea6769 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -174,15 +174,15 @@ int ip6_output(struct sk_buff *skb)
174 * xmit an sk_buff (used by TCP, SCTP and DCCP) 174 * xmit an sk_buff (used by TCP, SCTP and DCCP)
175 */ 175 */
176 176
177int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, 177int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
178 struct ipv6_txoptions *opt) 178 struct ipv6_txoptions *opt)
179{ 179{
180 struct net *net = sock_net(sk); 180 struct net *net = sock_net(sk);
181 struct ipv6_pinfo *np = inet6_sk(sk); 181 struct ipv6_pinfo *np = inet6_sk(sk);
182 struct in6_addr *first_hop = &fl->fl6_dst; 182 struct in6_addr *first_hop = &fl6->daddr;
183 struct dst_entry *dst = skb_dst(skb); 183 struct dst_entry *dst = skb_dst(skb);
184 struct ipv6hdr *hdr; 184 struct ipv6hdr *hdr;
185 u8 proto = fl->proto; 185 u8 proto = fl6->flowi6_proto;
186 int seg_len = skb->len; 186 int seg_len = skb->len;
187 int hlimit = -1; 187 int hlimit = -1;
188 int tclass = 0; 188 int tclass = 0;
@@ -230,13 +230,13 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
230 if (hlimit < 0) 230 if (hlimit < 0)
231 hlimit = ip6_dst_hoplimit(dst); 231 hlimit = ip6_dst_hoplimit(dst);
232 232
233 *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel; 233 *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl6->flowlabel;
234 234
235 hdr->payload_len = htons(seg_len); 235 hdr->payload_len = htons(seg_len);
236 hdr->nexthdr = proto; 236 hdr->nexthdr = proto;
237 hdr->hop_limit = hlimit; 237 hdr->hop_limit = hlimit;
238 238
239 ipv6_addr_copy(&hdr->saddr, &fl->fl6_src); 239 ipv6_addr_copy(&hdr->saddr, &fl6->saddr);
240 ipv6_addr_copy(&hdr->daddr, first_hop); 240 ipv6_addr_copy(&hdr->daddr, first_hop);
241 241
242 skb->priority = sk->sk_priority; 242 skb->priority = sk->sk_priority;
@@ -274,13 +274,10 @@ int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev,
274{ 274{
275 struct ipv6_pinfo *np = inet6_sk(sk); 275 struct ipv6_pinfo *np = inet6_sk(sk);
276 struct ipv6hdr *hdr; 276 struct ipv6hdr *hdr;
277 int totlen;
278 277
279 skb->protocol = htons(ETH_P_IPV6); 278 skb->protocol = htons(ETH_P_IPV6);
280 skb->dev = dev; 279 skb->dev = dev;
281 280
282 totlen = len + sizeof(struct ipv6hdr);
283
284 skb_reset_network_header(skb); 281 skb_reset_network_header(skb);
285 skb_put(skb, sizeof(struct ipv6hdr)); 282 skb_put(skb, sizeof(struct ipv6hdr));
286 hdr = ipv6_hdr(skb); 283 hdr = ipv6_hdr(skb);
@@ -479,10 +476,13 @@ int ip6_forward(struct sk_buff *skb)
479 else 476 else
480 target = &hdr->daddr; 477 target = &hdr->daddr;
481 478
479 if (!rt->rt6i_peer)
480 rt6_bind_peer(rt, 1);
481
482 /* Limit redirects both by destination (here) 482 /* Limit redirects both by destination (here)
483 and by source (inside ndisc_send_redirect) 483 and by source (inside ndisc_send_redirect)
484 */ 484 */
485 if (xrlim_allow(dst, 1*HZ)) 485 if (inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ))
486 ndisc_send_redirect(skb, n, target); 486 ndisc_send_redirect(skb, n, target);
487 } else { 487 } else {
488 int addrtype = ipv6_addr_type(&hdr->saddr); 488 int addrtype = ipv6_addr_type(&hdr->saddr);
@@ -779,7 +779,7 @@ slow_path:
779 /* IF: it doesn't fit, use 'mtu' - the data space left */ 779 /* IF: it doesn't fit, use 'mtu' - the data space left */
780 if (len > mtu) 780 if (len > mtu)
781 len = mtu; 781 len = mtu;
782 /* IF: we are not sending upto and including the packet end 782 /* IF: we are not sending up to and including the packet end
783 then align the next start on an eight byte boundary */ 783 then align the next start on an eight byte boundary */
784 if (len < left) { 784 if (len < left) {
785 len &= ~7; 785 len &= ~7;
@@ -879,7 +879,7 @@ static inline int ip6_rt_check(struct rt6key *rt_key,
879 879
880static struct dst_entry *ip6_sk_dst_check(struct sock *sk, 880static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
881 struct dst_entry *dst, 881 struct dst_entry *dst,
882 struct flowi *fl) 882 struct flowi6 *fl6)
883{ 883{
884 struct ipv6_pinfo *np = inet6_sk(sk); 884 struct ipv6_pinfo *np = inet6_sk(sk);
885 struct rt6_info *rt = (struct rt6_info *)dst; 885 struct rt6_info *rt = (struct rt6_info *)dst;
@@ -904,11 +904,11 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
904 * sockets. 904 * sockets.
905 * 2. oif also should be the same. 905 * 2. oif also should be the same.
906 */ 906 */
907 if (ip6_rt_check(&rt->rt6i_dst, &fl->fl6_dst, np->daddr_cache) || 907 if (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) ||
908#ifdef CONFIG_IPV6_SUBTREES 908#ifdef CONFIG_IPV6_SUBTREES
909 ip6_rt_check(&rt->rt6i_src, &fl->fl6_src, np->saddr_cache) || 909 ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) ||
910#endif 910#endif
911 (fl->oif && fl->oif != dst->dev->ifindex)) { 911 (fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) {
912 dst_release(dst); 912 dst_release(dst);
913 dst = NULL; 913 dst = NULL;
914 } 914 }
@@ -918,22 +918,22 @@ out:
918} 918}
919 919
920static int ip6_dst_lookup_tail(struct sock *sk, 920static int ip6_dst_lookup_tail(struct sock *sk,
921 struct dst_entry **dst, struct flowi *fl) 921 struct dst_entry **dst, struct flowi6 *fl6)
922{ 922{
923 int err; 923 int err;
924 struct net *net = sock_net(sk); 924 struct net *net = sock_net(sk);
925 925
926 if (*dst == NULL) 926 if (*dst == NULL)
927 *dst = ip6_route_output(net, sk, fl); 927 *dst = ip6_route_output(net, sk, fl6);
928 928
929 if ((err = (*dst)->error)) 929 if ((err = (*dst)->error))
930 goto out_err_release; 930 goto out_err_release;
931 931
932 if (ipv6_addr_any(&fl->fl6_src)) { 932 if (ipv6_addr_any(&fl6->saddr)) {
933 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev, 933 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
934 &fl->fl6_dst, 934 &fl6->daddr,
935 sk ? inet6_sk(sk)->srcprefs : 0, 935 sk ? inet6_sk(sk)->srcprefs : 0,
936 &fl->fl6_src); 936 &fl6->saddr);
937 if (err) 937 if (err)
938 goto out_err_release; 938 goto out_err_release;
939 } 939 }
@@ -949,10 +949,10 @@ static int ip6_dst_lookup_tail(struct sock *sk,
949 */ 949 */
950 if ((*dst)->neighbour && !((*dst)->neighbour->nud_state & NUD_VALID)) { 950 if ((*dst)->neighbour && !((*dst)->neighbour->nud_state & NUD_VALID)) {
951 struct inet6_ifaddr *ifp; 951 struct inet6_ifaddr *ifp;
952 struct flowi fl_gw; 952 struct flowi6 fl_gw6;
953 int redirect; 953 int redirect;
954 954
955 ifp = ipv6_get_ifaddr(net, &fl->fl6_src, 955 ifp = ipv6_get_ifaddr(net, &fl6->saddr,
956 (*dst)->dev, 1); 956 (*dst)->dev, 1);
957 957
958 redirect = (ifp && ifp->flags & IFA_F_OPTIMISTIC); 958 redirect = (ifp && ifp->flags & IFA_F_OPTIMISTIC);
@@ -965,9 +965,9 @@ static int ip6_dst_lookup_tail(struct sock *sk,
965 * default router instead 965 * default router instead
966 */ 966 */
967 dst_release(*dst); 967 dst_release(*dst);
968 memcpy(&fl_gw, fl, sizeof(struct flowi)); 968 memcpy(&fl_gw6, fl6, sizeof(struct flowi6));
969 memset(&fl_gw.fl6_dst, 0, sizeof(struct in6_addr)); 969 memset(&fl_gw6.daddr, 0, sizeof(struct in6_addr));
970 *dst = ip6_route_output(net, sk, &fl_gw); 970 *dst = ip6_route_output(net, sk, &fl_gw6);
971 if ((err = (*dst)->error)) 971 if ((err = (*dst)->error))
972 goto out_err_release; 972 goto out_err_release;
973 } 973 }
@@ -988,43 +988,85 @@ out_err_release:
988 * ip6_dst_lookup - perform route lookup on flow 988 * ip6_dst_lookup - perform route lookup on flow
989 * @sk: socket which provides route info 989 * @sk: socket which provides route info
990 * @dst: pointer to dst_entry * for result 990 * @dst: pointer to dst_entry * for result
991 * @fl: flow to lookup 991 * @fl6: flow to lookup
992 * 992 *
993 * This function performs a route lookup on the given flow. 993 * This function performs a route lookup on the given flow.
994 * 994 *
995 * It returns zero on success, or a standard errno code on error. 995 * It returns zero on success, or a standard errno code on error.
996 */ 996 */
997int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl) 997int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi6 *fl6)
998{ 998{
999 *dst = NULL; 999 *dst = NULL;
1000 return ip6_dst_lookup_tail(sk, dst, fl); 1000 return ip6_dst_lookup_tail(sk, dst, fl6);
1001} 1001}
1002EXPORT_SYMBOL_GPL(ip6_dst_lookup); 1002EXPORT_SYMBOL_GPL(ip6_dst_lookup);
1003 1003
1004/** 1004/**
1005 * ip6_sk_dst_lookup - perform socket cached route lookup on flow 1005 * ip6_dst_lookup_flow - perform route lookup on flow with ipsec
1006 * @sk: socket which provides route info
1007 * @fl6: flow to lookup
1008 * @final_dst: final destination address for ipsec lookup
1009 * @can_sleep: we are in a sleepable context
1010 *
1011 * This function performs a route lookup on the given flow.
1012 *
1013 * It returns a valid dst pointer on success, or a pointer encoded
1014 * error code.
1015 */
1016struct dst_entry *ip6_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
1017 const struct in6_addr *final_dst,
1018 bool can_sleep)
1019{
1020 struct dst_entry *dst = NULL;
1021 int err;
1022
1023 err = ip6_dst_lookup_tail(sk, &dst, fl6);
1024 if (err)
1025 return ERR_PTR(err);
1026 if (final_dst)
1027 ipv6_addr_copy(&fl6->daddr, final_dst);
1028 if (can_sleep)
1029 fl6->flowi6_flags |= FLOWI_FLAG_CAN_SLEEP;
1030
1031 return xfrm_lookup(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
1032}
1033EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow);
1034
1035/**
1036 * ip6_sk_dst_lookup_flow - perform socket cached route lookup on flow
1006 * @sk: socket which provides the dst cache and route info 1037 * @sk: socket which provides the dst cache and route info
1007 * @dst: pointer to dst_entry * for result 1038 * @fl6: flow to lookup
1008 * @fl: flow to lookup 1039 * @final_dst: final destination address for ipsec lookup
1040 * @can_sleep: we are in a sleepable context
1009 * 1041 *
1010 * This function performs a route lookup on the given flow with the 1042 * This function performs a route lookup on the given flow with the
1011 * possibility of using the cached route in the socket if it is valid. 1043 * possibility of using the cached route in the socket if it is valid.
1012 * It will take the socket dst lock when operating on the dst cache. 1044 * It will take the socket dst lock when operating on the dst cache.
1013 * As a result, this function can only be used in process context. 1045 * As a result, this function can only be used in process context.
1014 * 1046 *
1015 * It returns zero on success, or a standard errno code on error. 1047 * It returns a valid dst pointer on success, or a pointer encoded
1048 * error code.
1016 */ 1049 */
1017int ip6_sk_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl) 1050struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
1051 const struct in6_addr *final_dst,
1052 bool can_sleep)
1018{ 1053{
1019 *dst = NULL; 1054 struct dst_entry *dst = sk_dst_check(sk, inet6_sk(sk)->dst_cookie);
1020 if (sk) { 1055 int err;
1021 *dst = sk_dst_check(sk, inet6_sk(sk)->dst_cookie); 1056
1022 *dst = ip6_sk_dst_check(sk, *dst, fl); 1057 dst = ip6_sk_dst_check(sk, dst, fl6);
1023 } 1058
1059 err = ip6_dst_lookup_tail(sk, &dst, fl6);
1060 if (err)
1061 return ERR_PTR(err);
1062 if (final_dst)
1063 ipv6_addr_copy(&fl6->daddr, final_dst);
1064 if (can_sleep)
1065 fl6->flowi6_flags |= FLOWI_FLAG_CAN_SLEEP;
1024 1066
1025 return ip6_dst_lookup_tail(sk, dst, fl); 1067 return xfrm_lookup(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
1026} 1068}
1027EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup); 1069EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow);
1028 1070
1029static inline int ip6_ufo_append_data(struct sock *sk, 1071static inline int ip6_ufo_append_data(struct sock *sk,
1030 int getfrag(void *from, char *to, int offset, int len, 1072 int getfrag(void *from, char *to, int offset, int len,
@@ -1061,7 +1103,6 @@ static inline int ip6_ufo_append_data(struct sock *sk,
1061 1103
1062 skb->ip_summed = CHECKSUM_PARTIAL; 1104 skb->ip_summed = CHECKSUM_PARTIAL;
1063 skb->csum = 0; 1105 skb->csum = 0;
1064 sk->sk_sndmsg_off = 0;
1065 } 1106 }
1066 1107
1067 err = skb_append_datato_frags(sk,skb, getfrag, from, 1108 err = skb_append_datato_frags(sk,skb, getfrag, from,
@@ -1104,7 +1145,7 @@ static inline struct ipv6_rt_hdr *ip6_rthdr_dup(struct ipv6_rt_hdr *src,
1104int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, 1145int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1105 int offset, int len, int odd, struct sk_buff *skb), 1146 int offset, int len, int odd, struct sk_buff *skb),
1106 void *from, int length, int transhdrlen, 1147 void *from, int length, int transhdrlen,
1107 int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl, 1148 int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6,
1108 struct rt6_info *rt, unsigned int flags, int dontfrag) 1149 struct rt6_info *rt, unsigned int flags, int dontfrag)
1109{ 1150{
1110 struct inet_sock *inet = inet_sk(sk); 1151 struct inet_sock *inet = inet_sk(sk);
@@ -1118,6 +1159,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1118 int err; 1159 int err;
1119 int offset = 0; 1160 int offset = 0;
1120 int csummode = CHECKSUM_NONE; 1161 int csummode = CHECKSUM_NONE;
1162 __u8 tx_flags = 0;
1121 1163
1122 if (flags&MSG_PROBE) 1164 if (flags&MSG_PROBE)
1123 return 0; 1165 return 0;
@@ -1161,7 +1203,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1161 } 1203 }
1162 dst_hold(&rt->dst); 1204 dst_hold(&rt->dst);
1163 inet->cork.dst = &rt->dst; 1205 inet->cork.dst = &rt->dst;
1164 inet->cork.fl = *fl; 1206 inet->cork.fl.u.ip6 = *fl6;
1165 np->cork.hop_limit = hlimit; 1207 np->cork.hop_limit = hlimit;
1166 np->cork.tclass = tclass; 1208 np->cork.tclass = tclass;
1167 mtu = np->pmtudisc == IPV6_PMTUDISC_PROBE ? 1209 mtu = np->pmtudisc == IPV6_PMTUDISC_PROBE ?
@@ -1182,7 +1224,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1182 transhdrlen += exthdrlen; 1224 transhdrlen += exthdrlen;
1183 } else { 1225 } else {
1184 rt = (struct rt6_info *)inet->cork.dst; 1226 rt = (struct rt6_info *)inet->cork.dst;
1185 fl = &inet->cork.fl; 1227 fl6 = &inet->cork.fl.u.ip6;
1186 opt = np->cork.opt; 1228 opt = np->cork.opt;
1187 transhdrlen = 0; 1229 transhdrlen = 0;
1188 exthdrlen = 0; 1230 exthdrlen = 0;
@@ -1197,11 +1239,18 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1197 1239
1198 if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) { 1240 if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) {
1199 if (inet->cork.length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) { 1241 if (inet->cork.length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) {
1200 ipv6_local_error(sk, EMSGSIZE, fl, mtu-exthdrlen); 1242 ipv6_local_error(sk, EMSGSIZE, fl6, mtu-exthdrlen);
1201 return -EMSGSIZE; 1243 return -EMSGSIZE;
1202 } 1244 }
1203 } 1245 }
1204 1246
1247 /* For UDP, check if TX timestamp is enabled */
1248 if (sk->sk_type == SOCK_DGRAM) {
1249 err = sock_tx_timestamp(sk, &tx_flags);
1250 if (err)
1251 goto error;
1252 }
1253
1205 /* 1254 /*
1206 * Let's try using as much space as possible. 1255 * Let's try using as much space as possible.
1207 * Use MTU if total length of the message fits into the MTU. 1256 * Use MTU if total length of the message fits into the MTU.
@@ -1222,7 +1271,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1222 if (length > mtu) { 1271 if (length > mtu) {
1223 int proto = sk->sk_protocol; 1272 int proto = sk->sk_protocol;
1224 if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){ 1273 if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){
1225 ipv6_local_rxpmtu(sk, fl, mtu-exthdrlen); 1274 ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
1226 return -EMSGSIZE; 1275 return -EMSGSIZE;
1227 } 1276 }
1228 1277
@@ -1306,6 +1355,12 @@ alloc_new_skb:
1306 sk->sk_allocation); 1355 sk->sk_allocation);
1307 if (unlikely(skb == NULL)) 1356 if (unlikely(skb == NULL))
1308 err = -ENOBUFS; 1357 err = -ENOBUFS;
1358 else {
1359 /* Only the initial fragment
1360 * is time stamped.
1361 */
1362 tx_flags = 0;
1363 }
1309 } 1364 }
1310 if (skb == NULL) 1365 if (skb == NULL)
1311 goto error; 1366 goto error;
@@ -1317,6 +1372,9 @@ alloc_new_skb:
1317 /* reserve for fragmentation */ 1372 /* reserve for fragmentation */
1318 skb_reserve(skb, hh_len+sizeof(struct frag_hdr)); 1373 skb_reserve(skb, hh_len+sizeof(struct frag_hdr));
1319 1374
1375 if (sk->sk_type == SOCK_DGRAM)
1376 skb_shinfo(skb)->tx_flags = tx_flags;
1377
1320 /* 1378 /*
1321 * Find where to start putting bytes 1379 * Find where to start putting bytes
1322 */ 1380 */
@@ -1458,8 +1516,8 @@ int ip6_push_pending_frames(struct sock *sk)
1458 struct ipv6hdr *hdr; 1516 struct ipv6hdr *hdr;
1459 struct ipv6_txoptions *opt = np->cork.opt; 1517 struct ipv6_txoptions *opt = np->cork.opt;
1460 struct rt6_info *rt = (struct rt6_info *)inet->cork.dst; 1518 struct rt6_info *rt = (struct rt6_info *)inet->cork.dst;
1461 struct flowi *fl = &inet->cork.fl; 1519 struct flowi6 *fl6 = &inet->cork.fl.u.ip6;
1462 unsigned char proto = fl->proto; 1520 unsigned char proto = fl6->flowi6_proto;
1463 int err = 0; 1521 int err = 0;
1464 1522
1465 if ((skb = __skb_dequeue(&sk->sk_write_queue)) == NULL) 1523 if ((skb = __skb_dequeue(&sk->sk_write_queue)) == NULL)
@@ -1484,7 +1542,7 @@ int ip6_push_pending_frames(struct sock *sk)
1484 if (np->pmtudisc < IPV6_PMTUDISC_DO) 1542 if (np->pmtudisc < IPV6_PMTUDISC_DO)
1485 skb->local_df = 1; 1543 skb->local_df = 1;
1486 1544
1487 ipv6_addr_copy(final_dst, &fl->fl6_dst); 1545 ipv6_addr_copy(final_dst, &fl6->daddr);
1488 __skb_pull(skb, skb_network_header_len(skb)); 1546 __skb_pull(skb, skb_network_header_len(skb));
1489 if (opt && opt->opt_flen) 1547 if (opt && opt->opt_flen)
1490 ipv6_push_frag_opts(skb, opt, &proto); 1548 ipv6_push_frag_opts(skb, opt, &proto);
@@ -1495,12 +1553,12 @@ int ip6_push_pending_frames(struct sock *sk)
1495 skb_reset_network_header(skb); 1553 skb_reset_network_header(skb);
1496 hdr = ipv6_hdr(skb); 1554 hdr = ipv6_hdr(skb);
1497 1555
1498 *(__be32*)hdr = fl->fl6_flowlabel | 1556 *(__be32*)hdr = fl6->flowlabel |
1499 htonl(0x60000000 | ((int)np->cork.tclass << 20)); 1557 htonl(0x60000000 | ((int)np->cork.tclass << 20));
1500 1558
1501 hdr->hop_limit = np->cork.hop_limit; 1559 hdr->hop_limit = np->cork.hop_limit;
1502 hdr->nexthdr = proto; 1560 hdr->nexthdr = proto;
1503 ipv6_addr_copy(&hdr->saddr, &fl->fl6_src); 1561 ipv6_addr_copy(&hdr->saddr, &fl6->saddr);
1504 ipv6_addr_copy(&hdr->daddr, final_dst); 1562 ipv6_addr_copy(&hdr->daddr, final_dst);
1505 1563
1506 skb->priority = sk->sk_priority; 1564 skb->priority = sk->sk_priority;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 4f4483e697bd..c1b1bd312df2 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -57,6 +57,7 @@
57MODULE_AUTHOR("Ville Nuorvala"); 57MODULE_AUTHOR("Ville Nuorvala");
58MODULE_DESCRIPTION("IPv6 tunneling device"); 58MODULE_DESCRIPTION("IPv6 tunneling device");
59MODULE_LICENSE("GPL"); 59MODULE_LICENSE("GPL");
60MODULE_ALIAS_NETDEV("ip6tnl0");
60 61
61#ifdef IP6_TNL_DEBUG 62#ifdef IP6_TNL_DEBUG
62#define IP6_TNL_TRACE(x...) printk(KERN_DEBUG "%s:" x "\n", __func__) 63#define IP6_TNL_TRACE(x...) printk(KERN_DEBUG "%s:" x "\n", __func__)
@@ -535,7 +536,6 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
535 int err; 536 int err;
536 struct sk_buff *skb2; 537 struct sk_buff *skb2;
537 struct iphdr *eiph; 538 struct iphdr *eiph;
538 struct flowi fl;
539 struct rtable *rt; 539 struct rtable *rt;
540 540
541 err = ip6_tnl_err(skb, IPPROTO_IPIP, opt, &rel_type, &rel_code, 541 err = ip6_tnl_err(skb, IPPROTO_IPIP, opt, &rel_type, &rel_code,
@@ -577,11 +577,11 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
577 eiph = ip_hdr(skb2); 577 eiph = ip_hdr(skb2);
578 578
579 /* Try to guess incoming interface */ 579 /* Try to guess incoming interface */
580 memset(&fl, 0, sizeof(fl)); 580 rt = ip_route_output_ports(dev_net(skb->dev), NULL,
581 fl.fl4_dst = eiph->saddr; 581 eiph->saddr, 0,
582 fl.fl4_tos = RT_TOS(eiph->tos); 582 0, 0,
583 fl.proto = IPPROTO_IPIP; 583 IPPROTO_IPIP, RT_TOS(eiph->tos), 0);
584 if (ip_route_output_key(dev_net(skb->dev), &rt, &fl)) 584 if (IS_ERR(rt))
585 goto out; 585 goto out;
586 586
587 skb2->dev = rt->dst.dev; 587 skb2->dev = rt->dst.dev;
@@ -590,15 +590,18 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
590 if (rt->rt_flags & RTCF_LOCAL) { 590 if (rt->rt_flags & RTCF_LOCAL) {
591 ip_rt_put(rt); 591 ip_rt_put(rt);
592 rt = NULL; 592 rt = NULL;
593 fl.fl4_dst = eiph->daddr; 593 rt = ip_route_output_ports(dev_net(skb->dev), NULL,
594 fl.fl4_src = eiph->saddr; 594 eiph->daddr, eiph->saddr,
595 fl.fl4_tos = eiph->tos; 595 0, 0,
596 if (ip_route_output_key(dev_net(skb->dev), &rt, &fl) || 596 IPPROTO_IPIP,
597 RT_TOS(eiph->tos), 0);
598 if (IS_ERR(rt) ||
597 rt->dst.dev->type != ARPHRD_TUNNEL) { 599 rt->dst.dev->type != ARPHRD_TUNNEL) {
598 ip_rt_put(rt); 600 if (!IS_ERR(rt))
601 ip_rt_put(rt);
599 goto out; 602 goto out;
600 } 603 }
601 skb_dst_set(skb2, (struct dst_entry *)rt); 604 skb_dst_set(skb2, &rt->dst);
602 } else { 605 } else {
603 ip_rt_put(rt); 606 ip_rt_put(rt);
604 if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos, 607 if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos,
@@ -881,7 +884,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
881static int ip6_tnl_xmit2(struct sk_buff *skb, 884static int ip6_tnl_xmit2(struct sk_buff *skb,
882 struct net_device *dev, 885 struct net_device *dev,
883 __u8 dsfield, 886 __u8 dsfield,
884 struct flowi *fl, 887 struct flowi6 *fl6,
885 int encap_limit, 888 int encap_limit,
886 __u32 *pmtu) 889 __u32 *pmtu)
887{ 890{
@@ -901,10 +904,16 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
901 if ((dst = ip6_tnl_dst_check(t)) != NULL) 904 if ((dst = ip6_tnl_dst_check(t)) != NULL)
902 dst_hold(dst); 905 dst_hold(dst);
903 else { 906 else {
904 dst = ip6_route_output(net, NULL, fl); 907 dst = ip6_route_output(net, NULL, fl6);
905 908
906 if (dst->error || xfrm_lookup(net, &dst, fl, NULL, 0) < 0) 909 if (dst->error)
907 goto tx_err_link_failure; 910 goto tx_err_link_failure;
911 dst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), NULL, 0);
912 if (IS_ERR(dst)) {
913 err = PTR_ERR(dst);
914 dst = NULL;
915 goto tx_err_link_failure;
916 }
908 } 917 }
909 918
910 tdev = dst->dev; 919 tdev = dst->dev;
@@ -954,7 +963,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
954 963
955 skb->transport_header = skb->network_header; 964 skb->transport_header = skb->network_header;
956 965
957 proto = fl->proto; 966 proto = fl6->flowi6_proto;
958 if (encap_limit >= 0) { 967 if (encap_limit >= 0) {
959 init_tel_txopt(&opt, encap_limit); 968 init_tel_txopt(&opt, encap_limit);
960 ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL); 969 ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
@@ -962,13 +971,13 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
962 skb_push(skb, sizeof(struct ipv6hdr)); 971 skb_push(skb, sizeof(struct ipv6hdr));
963 skb_reset_network_header(skb); 972 skb_reset_network_header(skb);
964 ipv6h = ipv6_hdr(skb); 973 ipv6h = ipv6_hdr(skb);
965 *(__be32*)ipv6h = fl->fl6_flowlabel | htonl(0x60000000); 974 *(__be32*)ipv6h = fl6->flowlabel | htonl(0x60000000);
966 dsfield = INET_ECN_encapsulate(0, dsfield); 975 dsfield = INET_ECN_encapsulate(0, dsfield);
967 ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield); 976 ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield);
968 ipv6h->hop_limit = t->parms.hop_limit; 977 ipv6h->hop_limit = t->parms.hop_limit;
969 ipv6h->nexthdr = proto; 978 ipv6h->nexthdr = proto;
970 ipv6_addr_copy(&ipv6h->saddr, &fl->fl6_src); 979 ipv6_addr_copy(&ipv6h->saddr, &fl6->saddr);
971 ipv6_addr_copy(&ipv6h->daddr, &fl->fl6_dst); 980 ipv6_addr_copy(&ipv6h->daddr, &fl6->daddr);
972 nf_reset(skb); 981 nf_reset(skb);
973 pkt_len = skb->len; 982 pkt_len = skb->len;
974 err = ip6_local_out(skb); 983 err = ip6_local_out(skb);
@@ -998,7 +1007,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
998 struct ip6_tnl *t = netdev_priv(dev); 1007 struct ip6_tnl *t = netdev_priv(dev);
999 struct iphdr *iph = ip_hdr(skb); 1008 struct iphdr *iph = ip_hdr(skb);
1000 int encap_limit = -1; 1009 int encap_limit = -1;
1001 struct flowi fl; 1010 struct flowi6 fl6;
1002 __u8 dsfield; 1011 __u8 dsfield;
1003 __u32 mtu; 1012 __u32 mtu;
1004 int err; 1013 int err;
@@ -1010,16 +1019,16 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
1010 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) 1019 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
1011 encap_limit = t->parms.encap_limit; 1020 encap_limit = t->parms.encap_limit;
1012 1021
1013 memcpy(&fl, &t->fl, sizeof (fl)); 1022 memcpy(&fl6, &t->fl.u.ip6, sizeof (fl6));
1014 fl.proto = IPPROTO_IPIP; 1023 fl6.flowi6_proto = IPPROTO_IPIP;
1015 1024
1016 dsfield = ipv4_get_dsfield(iph); 1025 dsfield = ipv4_get_dsfield(iph);
1017 1026
1018 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)) 1027 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
1019 fl.fl6_flowlabel |= htonl((__u32)iph->tos << IPV6_TCLASS_SHIFT) 1028 fl6.flowlabel |= htonl((__u32)iph->tos << IPV6_TCLASS_SHIFT)
1020 & IPV6_TCLASS_MASK; 1029 & IPV6_TCLASS_MASK;
1021 1030
1022 err = ip6_tnl_xmit2(skb, dev, dsfield, &fl, encap_limit, &mtu); 1031 err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
1023 if (err != 0) { 1032 if (err != 0) {
1024 /* XXX: send ICMP error even if DF is not set. */ 1033 /* XXX: send ICMP error even if DF is not set. */
1025 if (err == -EMSGSIZE) 1034 if (err == -EMSGSIZE)
@@ -1038,7 +1047,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
1038 struct ipv6hdr *ipv6h = ipv6_hdr(skb); 1047 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
1039 int encap_limit = -1; 1048 int encap_limit = -1;
1040 __u16 offset; 1049 __u16 offset;
1041 struct flowi fl; 1050 struct flowi6 fl6;
1042 __u8 dsfield; 1051 __u8 dsfield;
1043 __u32 mtu; 1052 __u32 mtu;
1044 int err; 1053 int err;
@@ -1060,16 +1069,16 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
1060 } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) 1069 } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
1061 encap_limit = t->parms.encap_limit; 1070 encap_limit = t->parms.encap_limit;
1062 1071
1063 memcpy(&fl, &t->fl, sizeof (fl)); 1072 memcpy(&fl6, &t->fl.u.ip6, sizeof (fl6));
1064 fl.proto = IPPROTO_IPV6; 1073 fl6.flowi6_proto = IPPROTO_IPV6;
1065 1074
1066 dsfield = ipv6_get_dsfield(ipv6h); 1075 dsfield = ipv6_get_dsfield(ipv6h);
1067 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)) 1076 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
1068 fl.fl6_flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK); 1077 fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
1069 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)) 1078 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
1070 fl.fl6_flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK); 1079 fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
1071 1080
1072 err = ip6_tnl_xmit2(skb, dev, dsfield, &fl, encap_limit, &mtu); 1081 err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
1073 if (err != 0) { 1082 if (err != 0) {
1074 if (err == -EMSGSIZE) 1083 if (err == -EMSGSIZE)
1075 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 1084 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
@@ -1132,21 +1141,21 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
1132{ 1141{
1133 struct net_device *dev = t->dev; 1142 struct net_device *dev = t->dev;
1134 struct ip6_tnl_parm *p = &t->parms; 1143 struct ip6_tnl_parm *p = &t->parms;
1135 struct flowi *fl = &t->fl; 1144 struct flowi6 *fl6 = &t->fl.u.ip6;
1136 1145
1137 memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); 1146 memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
1138 memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr)); 1147 memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));
1139 1148
1140 /* Set up flowi template */ 1149 /* Set up flowi template */
1141 ipv6_addr_copy(&fl->fl6_src, &p->laddr); 1150 ipv6_addr_copy(&fl6->saddr, &p->laddr);
1142 ipv6_addr_copy(&fl->fl6_dst, &p->raddr); 1151 ipv6_addr_copy(&fl6->daddr, &p->raddr);
1143 fl->oif = p->link; 1152 fl6->flowi6_oif = p->link;
1144 fl->fl6_flowlabel = 0; 1153 fl6->flowlabel = 0;
1145 1154
1146 if (!(p->flags&IP6_TNL_F_USE_ORIG_TCLASS)) 1155 if (!(p->flags&IP6_TNL_F_USE_ORIG_TCLASS))
1147 fl->fl6_flowlabel |= IPV6_TCLASS_MASK & p->flowinfo; 1156 fl6->flowlabel |= IPV6_TCLASS_MASK & p->flowinfo;
1148 if (!(p->flags&IP6_TNL_F_USE_ORIG_FLOWLABEL)) 1157 if (!(p->flags&IP6_TNL_F_USE_ORIG_FLOWLABEL))
1149 fl->fl6_flowlabel |= IPV6_FLOWLABEL_MASK & p->flowinfo; 1158 fl6->flowlabel |= IPV6_FLOWLABEL_MASK & p->flowinfo;
1150 1159
1151 ip6_tnl_set_cap(t); 1160 ip6_tnl_set_cap(t);
1152 1161
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 0e1d53bcf1e0..29e48593bf22 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -135,14 +135,15 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id)
135 return NULL; 135 return NULL;
136} 136}
137 137
138static int ip6mr_fib_lookup(struct net *net, struct flowi *flp, 138static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
139 struct mr6_table **mrt) 139 struct mr6_table **mrt)
140{ 140{
141 struct ip6mr_result res; 141 struct ip6mr_result res;
142 struct fib_lookup_arg arg = { .result = &res, }; 142 struct fib_lookup_arg arg = { .result = &res, };
143 int err; 143 int err;
144 144
145 err = fib_rules_lookup(net->ipv6.mr6_rules_ops, flp, 0, &arg); 145 err = fib_rules_lookup(net->ipv6.mr6_rules_ops,
146 flowi6_to_flowi(flp6), 0, &arg);
146 if (err < 0) 147 if (err < 0)
147 return err; 148 return err;
148 *mrt = res.mrt; 149 *mrt = res.mrt;
@@ -270,7 +271,7 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id)
270 return net->ipv6.mrt6; 271 return net->ipv6.mrt6;
271} 272}
272 273
273static int ip6mr_fib_lookup(struct net *net, struct flowi *flp, 274static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
274 struct mr6_table **mrt) 275 struct mr6_table **mrt)
275{ 276{
276 *mrt = net->ipv6.mrt6; 277 *mrt = net->ipv6.mrt6;
@@ -617,9 +618,9 @@ static int pim6_rcv(struct sk_buff *skb)
617 struct net_device *reg_dev = NULL; 618 struct net_device *reg_dev = NULL;
618 struct net *net = dev_net(skb->dev); 619 struct net *net = dev_net(skb->dev);
619 struct mr6_table *mrt; 620 struct mr6_table *mrt;
620 struct flowi fl = { 621 struct flowi6 fl6 = {
621 .iif = skb->dev->ifindex, 622 .flowi6_iif = skb->dev->ifindex,
622 .mark = skb->mark, 623 .flowi6_mark = skb->mark,
623 }; 624 };
624 int reg_vif_num; 625 int reg_vif_num;
625 626
@@ -644,7 +645,7 @@ static int pim6_rcv(struct sk_buff *skb)
644 ntohs(encap->payload_len) + sizeof(*pim) > skb->len) 645 ntohs(encap->payload_len) + sizeof(*pim) > skb->len)
645 goto drop; 646 goto drop;
646 647
647 if (ip6mr_fib_lookup(net, &fl, &mrt) < 0) 648 if (ip6mr_fib_lookup(net, &fl6, &mrt) < 0)
648 goto drop; 649 goto drop;
649 reg_vif_num = mrt->mroute_reg_vif_num; 650 reg_vif_num = mrt->mroute_reg_vif_num;
650 651
@@ -662,7 +663,7 @@ static int pim6_rcv(struct sk_buff *skb)
662 skb_pull(skb, (u8 *)encap - skb->data); 663 skb_pull(skb, (u8 *)encap - skb->data);
663 skb_reset_network_header(skb); 664 skb_reset_network_header(skb);
664 skb->protocol = htons(ETH_P_IPV6); 665 skb->protocol = htons(ETH_P_IPV6);
665 skb->ip_summed = 0; 666 skb->ip_summed = CHECKSUM_NONE;
666 skb->pkt_type = PACKET_HOST; 667 skb->pkt_type = PACKET_HOST;
667 668
668 skb_tunnel_rx(skb, reg_dev); 669 skb_tunnel_rx(skb, reg_dev);
@@ -687,14 +688,14 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb,
687{ 688{
688 struct net *net = dev_net(dev); 689 struct net *net = dev_net(dev);
689 struct mr6_table *mrt; 690 struct mr6_table *mrt;
690 struct flowi fl = { 691 struct flowi6 fl6 = {
691 .oif = dev->ifindex, 692 .flowi6_oif = dev->ifindex,
692 .iif = skb->skb_iif, 693 .flowi6_iif = skb->skb_iif,
693 .mark = skb->mark, 694 .flowi6_mark = skb->mark,
694 }; 695 };
695 int err; 696 int err;
696 697
697 err = ip6mr_fib_lookup(net, &fl, &mrt); 698 err = ip6mr_fib_lookup(net, &fl6, &mrt);
698 if (err < 0) 699 if (err < 0)
699 return err; 700 return err;
700 701
@@ -1039,7 +1040,6 @@ static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt,
1039 1040
1040 while((skb = __skb_dequeue(&uc->mfc_un.unres.unresolved))) { 1041 while((skb = __skb_dequeue(&uc->mfc_un.unres.unresolved))) {
1041 if (ipv6_hdr(skb)->version == 0) { 1042 if (ipv6_hdr(skb)->version == 0) {
1042 int err;
1043 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct ipv6hdr)); 1043 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct ipv6hdr));
1044 1044
1045 if (__ip6mr_fill_mroute(mrt, skb, c, NLMSG_DATA(nlh)) > 0) { 1045 if (__ip6mr_fill_mroute(mrt, skb, c, NLMSG_DATA(nlh)) > 0) {
@@ -1050,7 +1050,7 @@ static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt,
1050 skb_trim(skb, nlh->nlmsg_len); 1050 skb_trim(skb, nlh->nlmsg_len);
1051 ((struct nlmsgerr *)NLMSG_DATA(nlh))->error = -EMSGSIZE; 1051 ((struct nlmsgerr *)NLMSG_DATA(nlh))->error = -EMSGSIZE;
1052 } 1052 }
1053 err = rtnl_unicast(skb, net, NETLINK_CB(skb).pid); 1053 rtnl_unicast(skb, net, NETLINK_CB(skb).pid);
1054 } else 1054 } else
1055 ip6_mr_forward(net, mrt, skb, c); 1055 ip6_mr_forward(net, mrt, skb, c);
1056 } 1056 }
@@ -1548,13 +1548,13 @@ int ip6mr_sk_done(struct sock *sk)
1548struct sock *mroute6_socket(struct net *net, struct sk_buff *skb) 1548struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
1549{ 1549{
1550 struct mr6_table *mrt; 1550 struct mr6_table *mrt;
1551 struct flowi fl = { 1551 struct flowi6 fl6 = {
1552 .iif = skb->skb_iif, 1552 .flowi6_iif = skb->skb_iif,
1553 .oif = skb->dev->ifindex, 1553 .flowi6_oif = skb->dev->ifindex,
1554 .mark = skb->mark, 1554 .flowi6_mark = skb->mark,
1555 }; 1555 };
1556 1556
1557 if (ip6mr_fib_lookup(net, &fl, &mrt) < 0) 1557 if (ip6mr_fib_lookup(net, &fl6, &mrt) < 0)
1558 return NULL; 1558 return NULL;
1559 1559
1560 return mrt->mroute6_sk; 1560 return mrt->mroute6_sk;
@@ -1898,7 +1898,7 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
1898 struct mif_device *vif = &mrt->vif6_table[vifi]; 1898 struct mif_device *vif = &mrt->vif6_table[vifi];
1899 struct net_device *dev; 1899 struct net_device *dev;
1900 struct dst_entry *dst; 1900 struct dst_entry *dst;
1901 struct flowi fl; 1901 struct flowi6 fl6;
1902 1902
1903 if (vif->dev == NULL) 1903 if (vif->dev == NULL)
1904 goto out_free; 1904 goto out_free;
@@ -1916,12 +1916,12 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
1916 1916
1917 ipv6h = ipv6_hdr(skb); 1917 ipv6h = ipv6_hdr(skb);
1918 1918
1919 fl = (struct flowi) { 1919 fl6 = (struct flowi6) {
1920 .oif = vif->link, 1920 .flowi6_oif = vif->link,
1921 .fl6_dst = ipv6h->daddr, 1921 .daddr = ipv6h->daddr,
1922 }; 1922 };
1923 1923
1924 dst = ip6_route_output(net, NULL, &fl); 1924 dst = ip6_route_output(net, NULL, &fl6);
1925 if (!dst) 1925 if (!dst)
1926 goto out_free; 1926 goto out_free;
1927 1927
@@ -2044,13 +2044,13 @@ int ip6_mr_input(struct sk_buff *skb)
2044 struct mfc6_cache *cache; 2044 struct mfc6_cache *cache;
2045 struct net *net = dev_net(skb->dev); 2045 struct net *net = dev_net(skb->dev);
2046 struct mr6_table *mrt; 2046 struct mr6_table *mrt;
2047 struct flowi fl = { 2047 struct flowi6 fl6 = {
2048 .iif = skb->dev->ifindex, 2048 .flowi6_iif = skb->dev->ifindex,
2049 .mark = skb->mark, 2049 .flowi6_mark = skb->mark,
2050 }; 2050 };
2051 int err; 2051 int err;
2052 2052
2053 err = ip6mr_fib_lookup(net, &fl, &mrt); 2053 err = ip6mr_fib_lookup(net, &fl6, &mrt);
2054 if (err < 0) 2054 if (err < 0)
2055 return err; 2055 return err;
2056 2056
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index d1770e061c08..9cb191ecaba8 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -444,12 +444,12 @@ sticky_done:
444 { 444 {
445 struct ipv6_txoptions *opt = NULL; 445 struct ipv6_txoptions *opt = NULL;
446 struct msghdr msg; 446 struct msghdr msg;
447 struct flowi fl; 447 struct flowi6 fl6;
448 int junk; 448 int junk;
449 449
450 fl.fl6_flowlabel = 0; 450 memset(&fl6, 0, sizeof(fl6));
451 fl.oif = sk->sk_bound_dev_if; 451 fl6.flowi6_oif = sk->sk_bound_dev_if;
452 fl.mark = sk->sk_mark; 452 fl6.flowi6_mark = sk->sk_mark;
453 453
454 if (optlen == 0) 454 if (optlen == 0)
455 goto update; 455 goto update;
@@ -475,7 +475,7 @@ sticky_done:
475 msg.msg_controllen = optlen; 475 msg.msg_controllen = optlen;
476 msg.msg_control = (void*)(opt+1); 476 msg.msg_control = (void*)(opt+1);
477 477
478 retv = datagram_send_ctl(net, &msg, &fl, opt, &junk, &junk, 478 retv = datagram_send_ctl(net, &msg, &fl6, opt, &junk, &junk,
479 &junk); 479 &junk);
480 if (retv) 480 if (retv)
481 goto done; 481 goto done;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 49f986d626a0..76b893771e6e 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -319,7 +319,6 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
319{ 319{
320 struct in6_addr *source, *group; 320 struct in6_addr *source, *group;
321 struct ipv6_mc_socklist *pmc; 321 struct ipv6_mc_socklist *pmc;
322 struct net_device *dev;
323 struct inet6_dev *idev; 322 struct inet6_dev *idev;
324 struct ipv6_pinfo *inet6 = inet6_sk(sk); 323 struct ipv6_pinfo *inet6 = inet6_sk(sk);
325 struct ip6_sf_socklist *psl; 324 struct ip6_sf_socklist *psl;
@@ -341,7 +340,6 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
341 rcu_read_unlock(); 340 rcu_read_unlock();
342 return -ENODEV; 341 return -ENODEV;
343 } 342 }
344 dev = idev->dev;
345 343
346 err = -EADDRNOTAVAIL; 344 err = -EADDRNOTAVAIL;
347 345
@@ -455,7 +453,6 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf)
455{ 453{
456 struct in6_addr *group; 454 struct in6_addr *group;
457 struct ipv6_mc_socklist *pmc; 455 struct ipv6_mc_socklist *pmc;
458 struct net_device *dev;
459 struct inet6_dev *idev; 456 struct inet6_dev *idev;
460 struct ipv6_pinfo *inet6 = inet6_sk(sk); 457 struct ipv6_pinfo *inet6 = inet6_sk(sk);
461 struct ip6_sf_socklist *newpsl, *psl; 458 struct ip6_sf_socklist *newpsl, *psl;
@@ -478,7 +475,6 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf)
478 rcu_read_unlock(); 475 rcu_read_unlock();
479 return -ENODEV; 476 return -ENODEV;
480 } 477 }
481 dev = idev->dev;
482 478
483 err = 0; 479 err = 0;
484 480
@@ -549,7 +545,6 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
549 struct in6_addr *group; 545 struct in6_addr *group;
550 struct ipv6_mc_socklist *pmc; 546 struct ipv6_mc_socklist *pmc;
551 struct inet6_dev *idev; 547 struct inet6_dev *idev;
552 struct net_device *dev;
553 struct ipv6_pinfo *inet6 = inet6_sk(sk); 548 struct ipv6_pinfo *inet6 = inet6_sk(sk);
554 struct ip6_sf_socklist *psl; 549 struct ip6_sf_socklist *psl;
555 struct net *net = sock_net(sk); 550 struct net *net = sock_net(sk);
@@ -566,7 +561,6 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
566 rcu_read_unlock(); 561 rcu_read_unlock();
567 return -ENODEV; 562 return -ENODEV;
568 } 563 }
569 dev = idev->dev;
570 564
571 err = -EADDRNOTAVAIL; 565 err = -EADDRNOTAVAIL;
572 /* 566 /*
@@ -1402,7 +1396,7 @@ static void mld_sendpack(struct sk_buff *skb)
1402 struct inet6_dev *idev; 1396 struct inet6_dev *idev;
1403 struct net *net = dev_net(skb->dev); 1397 struct net *net = dev_net(skb->dev);
1404 int err; 1398 int err;
1405 struct flowi fl; 1399 struct flowi6 fl6;
1406 struct dst_entry *dst; 1400 struct dst_entry *dst;
1407 1401
1408 rcu_read_lock(); 1402 rcu_read_lock();
@@ -1425,11 +1419,16 @@ static void mld_sendpack(struct sk_buff *skb)
1425 goto err_out; 1419 goto err_out;
1426 } 1420 }
1427 1421
1428 icmpv6_flow_init(net->ipv6.igmp_sk, &fl, ICMPV6_MLD2_REPORT, 1422 icmpv6_flow_init(net->ipv6.igmp_sk, &fl6, ICMPV6_MLD2_REPORT,
1429 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, 1423 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
1430 skb->dev->ifindex); 1424 skb->dev->ifindex);
1431 1425
1432 err = xfrm_lookup(net, &dst, &fl, NULL, 0); 1426 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
1427 err = 0;
1428 if (IS_ERR(dst)) {
1429 err = PTR_ERR(dst);
1430 dst = NULL;
1431 }
1433 skb_dst_set(skb, dst); 1432 skb_dst_set(skb, dst);
1434 if (err) 1433 if (err)
1435 goto err_out; 1434 goto err_out;
@@ -1732,7 +1731,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1732 u8 ra[8] = { IPPROTO_ICMPV6, 0, 1731 u8 ra[8] = { IPPROTO_ICMPV6, 0,
1733 IPV6_TLV_ROUTERALERT, 2, 0, 0, 1732 IPV6_TLV_ROUTERALERT, 2, 0, 0,
1734 IPV6_TLV_PADN, 0 }; 1733 IPV6_TLV_PADN, 0 };
1735 struct flowi fl; 1734 struct flowi6 fl6;
1736 struct dst_entry *dst; 1735 struct dst_entry *dst;
1737 1736
1738 if (type == ICMPV6_MGM_REDUCTION) 1737 if (type == ICMPV6_MGM_REDUCTION)
@@ -1792,13 +1791,15 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1792 goto err_out; 1791 goto err_out;
1793 } 1792 }
1794 1793
1795 icmpv6_flow_init(sk, &fl, type, 1794 icmpv6_flow_init(sk, &fl6, type,
1796 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, 1795 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
1797 skb->dev->ifindex); 1796 skb->dev->ifindex);
1798 1797
1799 err = xfrm_lookup(net, &dst, &fl, NULL, 0); 1798 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
1800 if (err) 1799 if (IS_ERR(dst)) {
1800 err = PTR_ERR(dst);
1801 goto err_out; 1801 goto err_out;
1802 }
1802 1803
1803 skb_dst_set(skb, dst); 1804 skb_dst_set(skb, dst);
1804 err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, skb, NULL, skb->dev, 1805 err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, skb, NULL, skb->dev,
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index d6e9599d0705..9b210482fb05 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -203,18 +203,20 @@ static inline int mip6_report_rl_allow(struct timeval *stamp,
203 return allow; 203 return allow;
204} 204}
205 205
206static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, struct flowi *fl) 206static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb,
207 const struct flowi *fl)
207{ 208{
208 struct net *net = xs_net(x); 209 struct net *net = xs_net(x);
209 struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb; 210 struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb;
211 const struct flowi6 *fl6 = &fl->u.ip6;
210 struct ipv6_destopt_hao *hao = NULL; 212 struct ipv6_destopt_hao *hao = NULL;
211 struct xfrm_selector sel; 213 struct xfrm_selector sel;
212 int offset; 214 int offset;
213 struct timeval stamp; 215 struct timeval stamp;
214 int err = 0; 216 int err = 0;
215 217
216 if (unlikely(fl->proto == IPPROTO_MH && 218 if (unlikely(fl6->flowi6_proto == IPPROTO_MH &&
217 fl->fl_mh_type <= IP6_MH_TYPE_MAX)) 219 fl6->fl6_mh_type <= IP6_MH_TYPE_MAX))
218 goto out; 220 goto out;
219 221
220 if (likely(opt->dsthao)) { 222 if (likely(opt->dsthao)) {
@@ -239,14 +241,14 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, struct
239 sizeof(sel.saddr)); 241 sizeof(sel.saddr));
240 sel.prefixlen_s = 128; 242 sel.prefixlen_s = 128;
241 sel.family = AF_INET6; 243 sel.family = AF_INET6;
242 sel.proto = fl->proto; 244 sel.proto = fl6->flowi6_proto;
243 sel.dport = xfrm_flowi_dport(fl); 245 sel.dport = xfrm_flowi_dport(fl, &fl6->uli);
244 if (sel.dport) 246 if (sel.dport)
245 sel.dport_mask = htons(~0); 247 sel.dport_mask = htons(~0);
246 sel.sport = xfrm_flowi_sport(fl); 248 sel.sport = xfrm_flowi_sport(fl, &fl6->uli);
247 if (sel.sport) 249 if (sel.sport)
248 sel.sport_mask = htons(~0); 250 sel.sport_mask = htons(~0);
249 sel.ifindex = fl->oif; 251 sel.ifindex = fl6->flowi6_oif;
250 252
251 err = km_report(net, IPPROTO_DSTOPTS, &sel, 253 err = km_report(net, IPPROTO_DSTOPTS, &sel,
252 (hao ? (xfrm_address_t *)&hao->addr : NULL)); 254 (hao ? (xfrm_address_t *)&hao->addr : NULL));
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 2342545a5ee9..92f952d093db 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -341,6 +341,8 @@ int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int d
341 case ARPHRD_INFINIBAND: 341 case ARPHRD_INFINIBAND:
342 ipv6_ib_mc_map(addr, dev->broadcast, buf); 342 ipv6_ib_mc_map(addr, dev->broadcast, buf);
343 return 0; 343 return 0;
344 case ARPHRD_IPGRE:
345 return ipv6_ipgre_mc_map(addr, dev->broadcast, buf);
344 default: 346 default:
345 if (dir) { 347 if (dir) {
346 memcpy(buf, dev->broadcast, dev->addr_len); 348 memcpy(buf, dev->broadcast, dev->addr_len);
@@ -511,7 +513,7 @@ void ndisc_send_skb(struct sk_buff *skb,
511 const struct in6_addr *saddr, 513 const struct in6_addr *saddr,
512 struct icmp6hdr *icmp6h) 514 struct icmp6hdr *icmp6h)
513{ 515{
514 struct flowi fl; 516 struct flowi6 fl6;
515 struct dst_entry *dst; 517 struct dst_entry *dst;
516 struct net *net = dev_net(dev); 518 struct net *net = dev_net(dev);
517 struct sock *sk = net->ipv6.ndisc_sk; 519 struct sock *sk = net->ipv6.ndisc_sk;
@@ -521,7 +523,7 @@ void ndisc_send_skb(struct sk_buff *skb,
521 523
522 type = icmp6h->icmp6_type; 524 type = icmp6h->icmp6_type;
523 525
524 icmpv6_flow_init(sk, &fl, type, saddr, daddr, dev->ifindex); 526 icmpv6_flow_init(sk, &fl6, type, saddr, daddr, dev->ifindex);
525 527
526 dst = icmp6_dst_alloc(dev, neigh, daddr); 528 dst = icmp6_dst_alloc(dev, neigh, daddr);
527 if (!dst) { 529 if (!dst) {
@@ -529,8 +531,8 @@ void ndisc_send_skb(struct sk_buff *skb,
529 return; 531 return;
530 } 532 }
531 533
532 err = xfrm_lookup(net, &dst, &fl, NULL, 0); 534 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
533 if (err < 0) { 535 if (IS_ERR(dst)) {
534 kfree_skb(skb); 536 kfree_skb(skb);
535 return; 537 return;
536 } 538 }
@@ -1515,7 +1517,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1515 struct rt6_info *rt; 1517 struct rt6_info *rt;
1516 struct dst_entry *dst; 1518 struct dst_entry *dst;
1517 struct inet6_dev *idev; 1519 struct inet6_dev *idev;
1518 struct flowi fl; 1520 struct flowi6 fl6;
1519 u8 *opt; 1521 u8 *opt;
1520 int rd_len; 1522 int rd_len;
1521 int err; 1523 int err;
@@ -1535,15 +1537,15 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1535 return; 1537 return;
1536 } 1538 }
1537 1539
1538 icmpv6_flow_init(sk, &fl, NDISC_REDIRECT, 1540 icmpv6_flow_init(sk, &fl6, NDISC_REDIRECT,
1539 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex); 1541 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
1540 1542
1541 dst = ip6_route_output(net, NULL, &fl); 1543 dst = ip6_route_output(net, NULL, &fl6);
1542 if (dst == NULL) 1544 if (dst == NULL)
1543 return; 1545 return;
1544 1546
1545 err = xfrm_lookup(net, &dst, &fl, NULL, 0); 1547 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
1546 if (err) 1548 if (IS_ERR(dst))
1547 return; 1549 return;
1548 1550
1549 rt = (struct rt6_info *) dst; 1551 rt = (struct rt6_info *) dst;
@@ -1553,7 +1555,9 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1553 "ICMPv6 Redirect: destination is not a neighbour.\n"); 1555 "ICMPv6 Redirect: destination is not a neighbour.\n");
1554 goto release; 1556 goto release;
1555 } 1557 }
1556 if (!xrlim_allow(dst, 1*HZ)) 1558 if (!rt->rt6i_peer)
1559 rt6_bind_peer(rt, 1);
1560 if (inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ))
1557 goto release; 1561 goto release;
1558 1562
1559 if (dev->addr_len) { 1563 if (dev->addr_len) {
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index 35915e8617f0..28bc1f644b7b 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -15,14 +15,14 @@ int ip6_route_me_harder(struct sk_buff *skb)
15 struct net *net = dev_net(skb_dst(skb)->dev); 15 struct net *net = dev_net(skb_dst(skb)->dev);
16 struct ipv6hdr *iph = ipv6_hdr(skb); 16 struct ipv6hdr *iph = ipv6_hdr(skb);
17 struct dst_entry *dst; 17 struct dst_entry *dst;
18 struct flowi fl = { 18 struct flowi6 fl6 = {
19 .oif = skb->sk ? skb->sk->sk_bound_dev_if : 0, 19 .flowi6_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0,
20 .mark = skb->mark, 20 .flowi6_mark = skb->mark,
21 .fl6_dst = iph->daddr, 21 .daddr = iph->daddr,
22 .fl6_src = iph->saddr, 22 .saddr = iph->saddr,
23 }; 23 };
24 24
25 dst = ip6_route_output(net, skb->sk, &fl); 25 dst = ip6_route_output(net, skb->sk, &fl6);
26 if (dst->error) { 26 if (dst->error) {
27 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); 27 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
28 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n"); 28 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n");
@@ -37,9 +37,10 @@ int ip6_route_me_harder(struct sk_buff *skb)
37 37
38#ifdef CONFIG_XFRM 38#ifdef CONFIG_XFRM
39 if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && 39 if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
40 xfrm_decode_session(skb, &fl, AF_INET6) == 0) { 40 xfrm_decode_session(skb, flowi6_to_flowi(&fl6), AF_INET6) == 0) {
41 skb_dst_set(skb, NULL); 41 skb_dst_set(skb, NULL);
42 if (xfrm_lookup(net, &dst, &fl, skb->sk, 0)) 42 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), skb->sk, 0);
43 if (IS_ERR(dst))
43 return -1; 44 return -1;
44 skb_dst_set(skb, dst); 45 skb_dst_set(skb, dst);
45 } 46 }
@@ -89,9 +90,18 @@ static int nf_ip6_reroute(struct sk_buff *skb,
89 return 0; 90 return 0;
90} 91}
91 92
92static int nf_ip6_route(struct dst_entry **dst, struct flowi *fl) 93static int nf_ip6_route(struct net *net, struct dst_entry **dst,
94 struct flowi *fl, bool strict)
93{ 95{
94 *dst = ip6_route_output(&init_net, NULL, fl); 96 static const struct ipv6_pinfo fake_pinfo;
97 static const struct inet_sock fake_sk = {
98 /* makes ip6_route_output set RT6_LOOKUP_F_IFACE: */
99 .sk.sk_bound_dev_if = 1,
100 .pinet6 = (struct ipv6_pinfo *) &fake_pinfo,
101 };
102 const void *sk = strict ? &fake_sk : NULL;
103
104 *dst = ip6_route_output(net, sk, &fl->u.ip6);
95 return (*dst)->error; 105 return (*dst)->error;
96} 106}
97 107
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 7d227c644f72..5a1c6f27ffaf 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -410,7 +410,7 @@ ip6t_do_table(struct sk_buff *skb,
410 verdict = (unsigned)(-v) - 1; 410 verdict = (unsigned)(-v) - 1;
411 break; 411 break;
412 } 412 }
413 if (*stackptr == 0) 413 if (*stackptr <= origptr)
414 e = get_entry(table_base, 414 e = get_entry(table_base,
415 private->underflow[hook]); 415 private->underflow[hook]);
416 else 416 else
@@ -441,8 +441,8 @@ ip6t_do_table(struct sk_buff *skb,
441 break; 441 break;
442 } while (!acpar.hotdrop); 442 } while (!acpar.hotdrop);
443 443
444 xt_info_rdunlock_bh();
445 *stackptr = origptr; 444 *stackptr = origptr;
445 xt_info_rdunlock_bh();
446 446
447#ifdef DEBUG_ALLOW_ALL 447#ifdef DEBUG_ALLOW_ALL
448 return NF_ACCEPT; 448 return NF_ACCEPT;
@@ -1076,6 +1076,7 @@ static int compat_table_info(const struct xt_table_info *info,
1076 memcpy(newinfo, info, offsetof(struct xt_table_info, entries)); 1076 memcpy(newinfo, info, offsetof(struct xt_table_info, entries));
1077 newinfo->initial_entries = 0; 1077 newinfo->initial_entries = 0;
1078 loc_cpu_entry = info->entries[raw_smp_processor_id()]; 1078 loc_cpu_entry = info->entries[raw_smp_processor_id()];
1079 xt_compat_init_offsets(AF_INET6, info->number);
1079 xt_entry_foreach(iter, loc_cpu_entry, info->size) { 1080 xt_entry_foreach(iter, loc_cpu_entry, info->size) {
1080 ret = compat_calc_entry(iter, info, loc_cpu_entry, newinfo); 1081 ret = compat_calc_entry(iter, info, loc_cpu_entry, newinfo);
1081 if (ret != 0) 1082 if (ret != 0)
@@ -1274,6 +1275,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len)
1274 /* overflow check */ 1275 /* overflow check */
1275 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters)) 1276 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters))
1276 return -ENOMEM; 1277 return -ENOMEM;
1278 tmp.name[sizeof(tmp.name)-1] = 0;
1277 1279
1278 newinfo = xt_alloc_table_info(tmp.size); 1280 newinfo = xt_alloc_table_info(tmp.size);
1279 if (!newinfo) 1281 if (!newinfo)
@@ -1679,6 +1681,7 @@ translate_compat_table(struct net *net,
1679 duprintf("translate_compat_table: size %u\n", info->size); 1681 duprintf("translate_compat_table: size %u\n", info->size);
1680 j = 0; 1682 j = 0;
1681 xt_compat_lock(AF_INET6); 1683 xt_compat_lock(AF_INET6);
1684 xt_compat_init_offsets(AF_INET6, number);
1682 /* Walk through entries, checking offsets. */ 1685 /* Walk through entries, checking offsets. */
1683 xt_entry_foreach(iter0, entry0, total_size) { 1686 xt_entry_foreach(iter0, entry0, total_size) {
1684 ret = check_compat_entry_size_and_hooks(iter0, info, &size, 1687 ret = check_compat_entry_size_and_hooks(iter0, info, &size,
@@ -1820,6 +1823,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len)
1820 return -ENOMEM; 1823 return -ENOMEM;
1821 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters)) 1824 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters))
1822 return -ENOMEM; 1825 return -ENOMEM;
1826 tmp.name[sizeof(tmp.name)-1] = 0;
1823 1827
1824 newinfo = xt_alloc_table_info(tmp.size); 1828 newinfo = xt_alloc_table_info(tmp.size);
1825 if (!newinfo) 1829 if (!newinfo)
@@ -2049,6 +2053,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
2049 ret = -EFAULT; 2053 ret = -EFAULT;
2050 break; 2054 break;
2051 } 2055 }
2056 rev.name[sizeof(rev.name)-1] = 0;
2052 2057
2053 if (cmd == IP6T_SO_GET_REVISION_TARGET) 2058 if (cmd == IP6T_SO_GET_REVISION_TARGET)
2054 target = 1; 2059 target = 1;
@@ -2243,7 +2248,7 @@ static int __init ip6_tables_init(void)
2243 if (ret < 0) 2248 if (ret < 0)
2244 goto err1; 2249 goto err1;
2245 2250
2246 /* Noone else will be downing sem now, so we won't sleep */ 2251 /* No one else will be downing sem now, so we won't sleep */
2247 ret = xt_register_targets(ip6t_builtin_tg, ARRAY_SIZE(ip6t_builtin_tg)); 2252 ret = xt_register_targets(ip6t_builtin_tg, ARRAY_SIZE(ip6t_builtin_tg));
2248 if (ret < 0) 2253 if (ret < 0)
2249 goto err2; 2254 goto err2;
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index 09c88891a753..e6af8d72f26b 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -410,7 +410,7 @@ fallback:
410 if (p != NULL) { 410 if (p != NULL) {
411 sb_add(m, "%02x", *p++); 411 sb_add(m, "%02x", *p++);
412 for (i = 1; i < len; i++) 412 for (i = 1; i < len; i++)
413 sb_add(m, ":%02x", p[i]); 413 sb_add(m, ":%02x", *p++);
414 } 414 }
415 sb_add(m, " "); 415 sb_add(m, " ");
416 416
@@ -452,8 +452,7 @@ ip6t_log_packet(u_int8_t pf,
452 in ? in->name : "", 452 in ? in->name : "",
453 out ? out->name : ""); 453 out ? out->name : "");
454 454
455 /* MAC logging for input path only. */ 455 if (in != NULL)
456 if (in && !out)
457 dump_mac_header(m, loginfo, skb); 456 dump_mac_header(m, loginfo, skb);
458 457
459 dump_packet(m, loginfo, skb, skb_network_offset(skb), 1); 458 dump_packet(m, loginfo, skb, skb_network_offset(skb), 1);
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c
index bf998feac14e..28e74488a329 100644
--- a/net/ipv6/netfilter/ip6t_REJECT.c
+++ b/net/ipv6/netfilter/ip6t_REJECT.c
@@ -47,7 +47,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
47 struct ipv6hdr *ip6h; 47 struct ipv6hdr *ip6h;
48 struct dst_entry *dst = NULL; 48 struct dst_entry *dst = NULL;
49 u8 proto; 49 u8 proto;
50 struct flowi fl; 50 struct flowi6 fl6;
51 51
52 if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) || 52 if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) ||
53 (!(ipv6_addr_type(&oip6h->daddr) & IPV6_ADDR_UNICAST))) { 53 (!(ipv6_addr_type(&oip6h->daddr) & IPV6_ADDR_UNICAST))) {
@@ -89,19 +89,20 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
89 return; 89 return;
90 } 90 }
91 91
92 memset(&fl, 0, sizeof(fl)); 92 memset(&fl6, 0, sizeof(fl6));
93 fl.proto = IPPROTO_TCP; 93 fl6.flowi6_proto = IPPROTO_TCP;
94 ipv6_addr_copy(&fl.fl6_src, &oip6h->daddr); 94 ipv6_addr_copy(&fl6.saddr, &oip6h->daddr);
95 ipv6_addr_copy(&fl.fl6_dst, &oip6h->saddr); 95 ipv6_addr_copy(&fl6.daddr, &oip6h->saddr);
96 fl.fl_ip_sport = otcph.dest; 96 fl6.fl6_sport = otcph.dest;
97 fl.fl_ip_dport = otcph.source; 97 fl6.fl6_dport = otcph.source;
98 security_skb_classify_flow(oldskb, &fl); 98 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
99 dst = ip6_route_output(net, NULL, &fl); 99 dst = ip6_route_output(net, NULL, &fl6);
100 if (dst == NULL || dst->error) { 100 if (dst == NULL || dst->error) {
101 dst_release(dst); 101 dst_release(dst);
102 return; 102 return;
103 } 103 }
104 if (xfrm_lookup(net, &dst, &fl, NULL, 0)) 104 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
105 if (IS_ERR(dst))
105 return; 106 return;
106 107
107 hh_len = (dst->dev->hard_header_len + 15)&~15; 108 hh_len = (dst->dev->hard_header_len + 15)&~15;
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 79d43aa8fa8d..085727263812 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -45,6 +45,7 @@
45#include <linux/netfilter_ipv6.h> 45#include <linux/netfilter_ipv6.h>
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/module.h> 47#include <linux/module.h>
48#include <net/netfilter/ipv6/nf_defrag_ipv6.h>
48 49
49 50
50struct nf_ct_frag6_skb_cb 51struct nf_ct_frag6_skb_cb
@@ -73,7 +74,7 @@ static struct inet_frags nf_frags;
73static struct netns_frags nf_init_frags; 74static struct netns_frags nf_init_frags;
74 75
75#ifdef CONFIG_SYSCTL 76#ifdef CONFIG_SYSCTL
76struct ctl_table nf_ct_frag6_sysctl_table[] = { 77static struct ctl_table nf_ct_frag6_sysctl_table[] = {
77 { 78 {
78 .procname = "nf_conntrack_frag6_timeout", 79 .procname = "nf_conntrack_frag6_timeout",
79 .data = &nf_init_frags.timeout, 80 .data = &nf_init_frags.timeout,
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index 97c5b21b9674..cdd6d045e42e 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -71,7 +71,7 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
71 if (reasm == NULL) 71 if (reasm == NULL)
72 return NF_STOLEN; 72 return NF_STOLEN;
73 73
74 /* error occured or not fragmented */ 74 /* error occurred or not fragmented */
75 if (reasm == skb) 75 if (reasm == skb)
76 return NF_ACCEPT; 76 return NF_ACCEPT;
77 77
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index c5b0915d106b..4a1c3b46c56b 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -124,18 +124,18 @@ static __inline__ int icmpv6_filter(struct sock *sk, struct sk_buff *skb)
124} 124}
125 125
126#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 126#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
127static int (*mh_filter)(struct sock *sock, struct sk_buff *skb); 127typedef int mh_filter_t(struct sock *sock, struct sk_buff *skb);
128 128
129int rawv6_mh_filter_register(int (*filter)(struct sock *sock, 129static mh_filter_t __rcu *mh_filter __read_mostly;
130 struct sk_buff *skb)) 130
131int rawv6_mh_filter_register(mh_filter_t filter)
131{ 132{
132 rcu_assign_pointer(mh_filter, filter); 133 rcu_assign_pointer(mh_filter, filter);
133 return 0; 134 return 0;
134} 135}
135EXPORT_SYMBOL(rawv6_mh_filter_register); 136EXPORT_SYMBOL(rawv6_mh_filter_register);
136 137
137int rawv6_mh_filter_unregister(int (*filter)(struct sock *sock, 138int rawv6_mh_filter_unregister(mh_filter_t filter)
138 struct sk_buff *skb))
139{ 139{
140 rcu_assign_pointer(mh_filter, NULL); 140 rcu_assign_pointer(mh_filter, NULL);
141 synchronize_rcu(); 141 synchronize_rcu();
@@ -193,10 +193,10 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
193 * policy is placed in rawv6_rcv() because it is 193 * policy is placed in rawv6_rcv() because it is
194 * required for each socket. 194 * required for each socket.
195 */ 195 */
196 int (*filter)(struct sock *sock, struct sk_buff *skb); 196 mh_filter_t *filter;
197 197
198 filter = rcu_dereference(mh_filter); 198 filter = rcu_dereference(mh_filter);
199 filtered = filter ? filter(sk, skb) : 0; 199 filtered = filter ? (*filter)(sk, skb) : 0;
200 break; 200 break;
201 } 201 }
202#endif 202#endif
@@ -524,7 +524,7 @@ csum_copy_err:
524 goto out; 524 goto out;
525} 525}
526 526
527static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, 527static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
528 struct raw6_sock *rp) 528 struct raw6_sock *rp)
529{ 529{
530 struct sk_buff *skb; 530 struct sk_buff *skb;
@@ -586,11 +586,10 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
586 if (unlikely(csum)) 586 if (unlikely(csum))
587 tmp_csum = csum_sub(tmp_csum, csum_unfold(csum)); 587 tmp_csum = csum_sub(tmp_csum, csum_unfold(csum));
588 588
589 csum = csum_ipv6_magic(&fl->fl6_src, 589 csum = csum_ipv6_magic(&fl6->saddr, &fl6->daddr,
590 &fl->fl6_dst, 590 total_len, fl6->flowi6_proto, tmp_csum);
591 total_len, fl->proto, tmp_csum);
592 591
593 if (csum == 0 && fl->proto == IPPROTO_UDP) 592 if (csum == 0 && fl6->flowi6_proto == IPPROTO_UDP)
594 csum = CSUM_MANGLED_0; 593 csum = CSUM_MANGLED_0;
595 594
596 if (skb_store_bits(skb, offset, &csum, 2)) 595 if (skb_store_bits(skb, offset, &csum, 2))
@@ -603,7 +602,7 @@ out:
603} 602}
604 603
605static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, 604static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
606 struct flowi *fl, struct dst_entry **dstp, 605 struct flowi6 *fl6, struct dst_entry **dstp,
607 unsigned int flags) 606 unsigned int flags)
608{ 607{
609 struct ipv6_pinfo *np = inet6_sk(sk); 608 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -613,7 +612,7 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
613 struct rt6_info *rt = (struct rt6_info *)*dstp; 612 struct rt6_info *rt = (struct rt6_info *)*dstp;
614 613
615 if (length > rt->dst.dev->mtu) { 614 if (length > rt->dst.dev->mtu) {
616 ipv6_local_error(sk, EMSGSIZE, fl, rt->dst.dev->mtu); 615 ipv6_local_error(sk, EMSGSIZE, fl6, rt->dst.dev->mtu);
617 return -EMSGSIZE; 616 return -EMSGSIZE;
618 } 617 }
619 if (flags&MSG_PROBE) 618 if (flags&MSG_PROBE)
@@ -662,7 +661,7 @@ error:
662 return err; 661 return err;
663} 662}
664 663
665static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg) 664static int rawv6_probe_proto_opt(struct flowi6 *fl6, struct msghdr *msg)
666{ 665{
667 struct iovec *iov; 666 struct iovec *iov;
668 u8 __user *type = NULL; 667 u8 __user *type = NULL;
@@ -679,7 +678,7 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
679 if (!iov) 678 if (!iov)
680 continue; 679 continue;
681 680
682 switch (fl->proto) { 681 switch (fl6->flowi6_proto) {
683 case IPPROTO_ICMPV6: 682 case IPPROTO_ICMPV6:
684 /* check if one-byte field is readable or not. */ 683 /* check if one-byte field is readable or not. */
685 if (iov->iov_base && iov->iov_len < 1) 684 if (iov->iov_base && iov->iov_len < 1)
@@ -694,8 +693,8 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
694 code = iov->iov_base; 693 code = iov->iov_base;
695 694
696 if (type && code) { 695 if (type && code) {
697 if (get_user(fl->fl_icmp_type, type) || 696 if (get_user(fl6->fl6_icmp_type, type) ||
698 get_user(fl->fl_icmp_code, code)) 697 get_user(fl6->fl6_icmp_code, code))
699 return -EFAULT; 698 return -EFAULT;
700 probed = 1; 699 probed = 1;
701 } 700 }
@@ -706,7 +705,7 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
706 /* check if type field is readable or not. */ 705 /* check if type field is readable or not. */
707 if (iov->iov_len > 2 - len) { 706 if (iov->iov_len > 2 - len) {
708 u8 __user *p = iov->iov_base; 707 u8 __user *p = iov->iov_base;
709 if (get_user(fl->fl_mh_type, &p[2 - len])) 708 if (get_user(fl6->fl6_mh_type, &p[2 - len]))
710 return -EFAULT; 709 return -EFAULT;
711 probed = 1; 710 probed = 1;
712 } else 711 } else
@@ -735,7 +734,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
735 struct ipv6_txoptions *opt = NULL; 734 struct ipv6_txoptions *opt = NULL;
736 struct ip6_flowlabel *flowlabel = NULL; 735 struct ip6_flowlabel *flowlabel = NULL;
737 struct dst_entry *dst = NULL; 736 struct dst_entry *dst = NULL;
738 struct flowi fl; 737 struct flowi6 fl6;
739 int addr_len = msg->msg_namelen; 738 int addr_len = msg->msg_namelen;
740 int hlimit = -1; 739 int hlimit = -1;
741 int tclass = -1; 740 int tclass = -1;
@@ -756,9 +755,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
756 /* 755 /*
757 * Get and verify the address. 756 * Get and verify the address.
758 */ 757 */
759 memset(&fl, 0, sizeof(fl)); 758 memset(&fl6, 0, sizeof(fl6));
760 759
761 fl.mark = sk->sk_mark; 760 fl6.flowi6_mark = sk->sk_mark;
762 761
763 if (sin6) { 762 if (sin6) {
764 if (addr_len < SIN6_LEN_RFC2133) 763 if (addr_len < SIN6_LEN_RFC2133)
@@ -780,9 +779,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
780 779
781 daddr = &sin6->sin6_addr; 780 daddr = &sin6->sin6_addr;
782 if (np->sndflow) { 781 if (np->sndflow) {
783 fl.fl6_flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK; 782 fl6.flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK;
784 if (fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) { 783 if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {
785 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); 784 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
786 if (flowlabel == NULL) 785 if (flowlabel == NULL)
787 return -EINVAL; 786 return -EINVAL;
788 daddr = &flowlabel->dst; 787 daddr = &flowlabel->dst;
@@ -800,32 +799,32 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
800 if (addr_len >= sizeof(struct sockaddr_in6) && 799 if (addr_len >= sizeof(struct sockaddr_in6) &&
801 sin6->sin6_scope_id && 800 sin6->sin6_scope_id &&
802 ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL) 801 ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
803 fl.oif = sin6->sin6_scope_id; 802 fl6.flowi6_oif = sin6->sin6_scope_id;
804 } else { 803 } else {
805 if (sk->sk_state != TCP_ESTABLISHED) 804 if (sk->sk_state != TCP_ESTABLISHED)
806 return -EDESTADDRREQ; 805 return -EDESTADDRREQ;
807 806
808 proto = inet->inet_num; 807 proto = inet->inet_num;
809 daddr = &np->daddr; 808 daddr = &np->daddr;
810 fl.fl6_flowlabel = np->flow_label; 809 fl6.flowlabel = np->flow_label;
811 } 810 }
812 811
813 if (fl.oif == 0) 812 if (fl6.flowi6_oif == 0)
814 fl.oif = sk->sk_bound_dev_if; 813 fl6.flowi6_oif = sk->sk_bound_dev_if;
815 814
816 if (msg->msg_controllen) { 815 if (msg->msg_controllen) {
817 opt = &opt_space; 816 opt = &opt_space;
818 memset(opt, 0, sizeof(struct ipv6_txoptions)); 817 memset(opt, 0, sizeof(struct ipv6_txoptions));
819 opt->tot_len = sizeof(struct ipv6_txoptions); 818 opt->tot_len = sizeof(struct ipv6_txoptions);
820 819
821 err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit, 820 err = datagram_send_ctl(sock_net(sk), msg, &fl6, opt, &hlimit,
822 &tclass, &dontfrag); 821 &tclass, &dontfrag);
823 if (err < 0) { 822 if (err < 0) {
824 fl6_sock_release(flowlabel); 823 fl6_sock_release(flowlabel);
825 return err; 824 return err;
826 } 825 }
827 if ((fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) { 826 if ((fl6.flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) {
828 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); 827 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
829 if (flowlabel == NULL) 828 if (flowlabel == NULL)
830 return -EINVAL; 829 return -EINVAL;
831 } 830 }
@@ -838,40 +837,31 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
838 opt = fl6_merge_options(&opt_space, flowlabel, opt); 837 opt = fl6_merge_options(&opt_space, flowlabel, opt);
839 opt = ipv6_fixup_options(&opt_space, opt); 838 opt = ipv6_fixup_options(&opt_space, opt);
840 839
841 fl.proto = proto; 840 fl6.flowi6_proto = proto;
842 err = rawv6_probe_proto_opt(&fl, msg); 841 err = rawv6_probe_proto_opt(&fl6, msg);
843 if (err) 842 if (err)
844 goto out; 843 goto out;
845 844
846 if (!ipv6_addr_any(daddr)) 845 if (!ipv6_addr_any(daddr))
847 ipv6_addr_copy(&fl.fl6_dst, daddr); 846 ipv6_addr_copy(&fl6.daddr, daddr);
848 else 847 else
849 fl.fl6_dst.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */ 848 fl6.daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */
850 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 849 if (ipv6_addr_any(&fl6.saddr) && !ipv6_addr_any(&np->saddr))
851 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 850 ipv6_addr_copy(&fl6.saddr, &np->saddr);
852 851
853 final_p = fl6_update_dst(&fl, opt, &final); 852 final_p = fl6_update_dst(&fl6, opt, &final);
854 853
855 if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) 854 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
856 fl.oif = np->mcast_oif; 855 fl6.flowi6_oif = np->mcast_oif;
857 security_sk_classify_flow(sk, &fl); 856 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
858 857
859 err = ip6_dst_lookup(sk, &dst, &fl); 858 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
860 if (err) 859 if (IS_ERR(dst)) {
860 err = PTR_ERR(dst);
861 goto out; 861 goto out;
862 if (final_p)
863 ipv6_addr_copy(&fl.fl6_dst, final_p);
864
865 err = __xfrm_lookup(sock_net(sk), &dst, &fl, sk, XFRM_LOOKUP_WAIT);
866 if (err < 0) {
867 if (err == -EREMOTE)
868 err = ip6_dst_blackhole(sk, &dst, &fl);
869 if (err < 0)
870 goto out;
871 } 862 }
872
873 if (hlimit < 0) { 863 if (hlimit < 0) {
874 if (ipv6_addr_is_multicast(&fl.fl6_dst)) 864 if (ipv6_addr_is_multicast(&fl6.daddr))
875 hlimit = np->mcast_hops; 865 hlimit = np->mcast_hops;
876 else 866 else
877 hlimit = np->hop_limit; 867 hlimit = np->hop_limit;
@@ -890,17 +880,17 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
890 880
891back_from_confirm: 881back_from_confirm:
892 if (inet->hdrincl) 882 if (inet->hdrincl)
893 err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, &dst, msg->msg_flags); 883 err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl6, &dst, msg->msg_flags);
894 else { 884 else {
895 lock_sock(sk); 885 lock_sock(sk);
896 err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, 886 err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov,
897 len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst, 887 len, 0, hlimit, tclass, opt, &fl6, (struct rt6_info*)dst,
898 msg->msg_flags, dontfrag); 888 msg->msg_flags, dontfrag);
899 889
900 if (err) 890 if (err)
901 ip6_flush_pending_frames(sk); 891 ip6_flush_pending_frames(sk);
902 else if (!(msg->msg_flags & MSG_MORE)) 892 else if (!(msg->msg_flags & MSG_MORE))
903 err = rawv6_push_pending_frames(sk, &fl, rp); 893 err = rawv6_push_pending_frames(sk, &fl6, rp);
904 release_sock(sk); 894 release_sock(sk);
905 } 895 }
906done: 896done:
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a998db6e7895..fd0eec6f88c6 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -97,6 +97,36 @@ static struct rt6_info *rt6_get_route_info(struct net *net,
97 struct in6_addr *gwaddr, int ifindex); 97 struct in6_addr *gwaddr, int ifindex);
98#endif 98#endif
99 99
100static u32 *ipv6_cow_metrics(struct dst_entry *dst, unsigned long old)
101{
102 struct rt6_info *rt = (struct rt6_info *) dst;
103 struct inet_peer *peer;
104 u32 *p = NULL;
105
106 if (!rt->rt6i_peer)
107 rt6_bind_peer(rt, 1);
108
109 peer = rt->rt6i_peer;
110 if (peer) {
111 u32 *old_p = __DST_METRICS_PTR(old);
112 unsigned long prev, new;
113
114 p = peer->metrics;
115 if (inet_metrics_new(peer))
116 memcpy(p, old_p, sizeof(u32) * RTAX_MAX);
117
118 new = (unsigned long) p;
119 prev = cmpxchg(&dst->_metrics, old, new);
120
121 if (prev != old) {
122 p = __DST_METRICS_PTR(prev);
123 if (prev & DST_METRICS_READ_ONLY)
124 p = NULL;
125 }
126 }
127 return p;
128}
129
100static struct dst_ops ip6_dst_ops_template = { 130static struct dst_ops ip6_dst_ops_template = {
101 .family = AF_INET6, 131 .family = AF_INET6,
102 .protocol = cpu_to_be16(ETH_P_IPV6), 132 .protocol = cpu_to_be16(ETH_P_IPV6),
@@ -105,6 +135,7 @@ static struct dst_ops ip6_dst_ops_template = {
105 .check = ip6_dst_check, 135 .check = ip6_dst_check,
106 .default_advmss = ip6_default_advmss, 136 .default_advmss = ip6_default_advmss,
107 .default_mtu = ip6_default_mtu, 137 .default_mtu = ip6_default_mtu,
138 .cow_metrics = ipv6_cow_metrics,
108 .destroy = ip6_dst_destroy, 139 .destroy = ip6_dst_destroy,
109 .ifdown = ip6_dst_ifdown, 140 .ifdown = ip6_dst_ifdown,
110 .negative_advice = ip6_negative_advice, 141 .negative_advice = ip6_negative_advice,
@@ -122,6 +153,12 @@ static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu)
122{ 153{
123} 154}
124 155
156static u32 *ip6_rt_blackhole_cow_metrics(struct dst_entry *dst,
157 unsigned long old)
158{
159 return NULL;
160}
161
125static struct dst_ops ip6_dst_blackhole_ops = { 162static struct dst_ops ip6_dst_blackhole_ops = {
126 .family = AF_INET6, 163 .family = AF_INET6,
127 .protocol = cpu_to_be16(ETH_P_IPV6), 164 .protocol = cpu_to_be16(ETH_P_IPV6),
@@ -130,6 +167,11 @@ static struct dst_ops ip6_dst_blackhole_ops = {
130 .default_mtu = ip6_blackhole_default_mtu, 167 .default_mtu = ip6_blackhole_default_mtu,
131 .default_advmss = ip6_default_advmss, 168 .default_advmss = ip6_default_advmss,
132 .update_pmtu = ip6_rt_blackhole_update_pmtu, 169 .update_pmtu = ip6_rt_blackhole_update_pmtu,
170 .cow_metrics = ip6_rt_blackhole_cow_metrics,
171};
172
173static const u32 ip6_template_metrics[RTAX_MAX] = {
174 [RTAX_HOPLIMIT - 1] = 255,
133}; 175};
134 176
135static struct rt6_info ip6_null_entry_template = { 177static struct rt6_info ip6_null_entry_template = {
@@ -187,7 +229,7 @@ static struct rt6_info ip6_blk_hole_entry_template = {
187/* allocate dst with ip6_dst_ops */ 229/* allocate dst with ip6_dst_ops */
188static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops) 230static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops)
189{ 231{
190 return (struct rt6_info *)dst_alloc(ops); 232 return (struct rt6_info *)dst_alloc(ops, 0);
191} 233}
192 234
193static void ip6_dst_destroy(struct dst_entry *dst) 235static void ip6_dst_destroy(struct dst_entry *dst)
@@ -206,6 +248,13 @@ static void ip6_dst_destroy(struct dst_entry *dst)
206 } 248 }
207} 249}
208 250
251static atomic_t __rt6_peer_genid = ATOMIC_INIT(0);
252
253static u32 rt6_peer_genid(void)
254{
255 return atomic_read(&__rt6_peer_genid);
256}
257
209void rt6_bind_peer(struct rt6_info *rt, int create) 258void rt6_bind_peer(struct rt6_info *rt, int create)
210{ 259{
211 struct inet_peer *peer; 260 struct inet_peer *peer;
@@ -213,6 +262,8 @@ void rt6_bind_peer(struct rt6_info *rt, int create)
213 peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create); 262 peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create);
214 if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL) 263 if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL)
215 inet_putpeer(peer); 264 inet_putpeer(peer);
265 else
266 rt->rt6i_peer_genid = rt6_peer_genid();
216} 267}
217 268
218static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, 269static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
@@ -555,17 +606,17 @@ do { \
555 606
556static struct rt6_info *ip6_pol_route_lookup(struct net *net, 607static struct rt6_info *ip6_pol_route_lookup(struct net *net,
557 struct fib6_table *table, 608 struct fib6_table *table,
558 struct flowi *fl, int flags) 609 struct flowi6 *fl6, int flags)
559{ 610{
560 struct fib6_node *fn; 611 struct fib6_node *fn;
561 struct rt6_info *rt; 612 struct rt6_info *rt;
562 613
563 read_lock_bh(&table->tb6_lock); 614 read_lock_bh(&table->tb6_lock);
564 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); 615 fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
565restart: 616restart:
566 rt = fn->leaf; 617 rt = fn->leaf;
567 rt = rt6_device_match(net, rt, &fl->fl6_src, fl->oif, flags); 618 rt = rt6_device_match(net, rt, &fl6->saddr, fl6->flowi6_oif, flags);
568 BACKTRACK(net, &fl->fl6_src); 619 BACKTRACK(net, &fl6->saddr);
569out: 620out:
570 dst_use(&rt->dst, jiffies); 621 dst_use(&rt->dst, jiffies);
571 read_unlock_bh(&table->tb6_lock); 622 read_unlock_bh(&table->tb6_lock);
@@ -576,19 +627,19 @@ out:
576struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr, 627struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr,
577 const struct in6_addr *saddr, int oif, int strict) 628 const struct in6_addr *saddr, int oif, int strict)
578{ 629{
579 struct flowi fl = { 630 struct flowi6 fl6 = {
580 .oif = oif, 631 .flowi6_oif = oif,
581 .fl6_dst = *daddr, 632 .daddr = *daddr,
582 }; 633 };
583 struct dst_entry *dst; 634 struct dst_entry *dst;
584 int flags = strict ? RT6_LOOKUP_F_IFACE : 0; 635 int flags = strict ? RT6_LOOKUP_F_IFACE : 0;
585 636
586 if (saddr) { 637 if (saddr) {
587 memcpy(&fl.fl6_src, saddr, sizeof(*saddr)); 638 memcpy(&fl6.saddr, saddr, sizeof(*saddr));
588 flags |= RT6_LOOKUP_F_HAS_SADDR; 639 flags |= RT6_LOOKUP_F_HAS_SADDR;
589 } 640 }
590 641
591 dst = fib6_rule_lookup(net, &fl, flags, ip6_pol_route_lookup); 642 dst = fib6_rule_lookup(net, &fl6, flags, ip6_pol_route_lookup);
592 if (dst->error == 0) 643 if (dst->error == 0)
593 return (struct rt6_info *) dst; 644 return (struct rt6_info *) dst;
594 645
@@ -709,7 +760,7 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d
709} 760}
710 761
711static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif, 762static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif,
712 struct flowi *fl, int flags) 763 struct flowi6 *fl6, int flags)
713{ 764{
714 struct fib6_node *fn; 765 struct fib6_node *fn;
715 struct rt6_info *rt, *nrt; 766 struct rt6_info *rt, *nrt;
@@ -724,12 +775,12 @@ relookup:
724 read_lock_bh(&table->tb6_lock); 775 read_lock_bh(&table->tb6_lock);
725 776
726restart_2: 777restart_2:
727 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); 778 fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
728 779
729restart: 780restart:
730 rt = rt6_select(fn, oif, strict | reachable); 781 rt = rt6_select(fn, oif, strict | reachable);
731 782
732 BACKTRACK(net, &fl->fl6_src); 783 BACKTRACK(net, &fl6->saddr);
733 if (rt == net->ipv6.ip6_null_entry || 784 if (rt == net->ipv6.ip6_null_entry ||
734 rt->rt6i_flags & RTF_CACHE) 785 rt->rt6i_flags & RTF_CACHE)
735 goto out; 786 goto out;
@@ -738,9 +789,11 @@ restart:
738 read_unlock_bh(&table->tb6_lock); 789 read_unlock_bh(&table->tb6_lock);
739 790
740 if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) 791 if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP))
741 nrt = rt6_alloc_cow(rt, &fl->fl6_dst, &fl->fl6_src); 792 nrt = rt6_alloc_cow(rt, &fl6->daddr, &fl6->saddr);
793 else if (!(rt->dst.flags & DST_HOST))
794 nrt = rt6_alloc_clone(rt, &fl6->daddr);
742 else 795 else
743 nrt = rt6_alloc_clone(rt, &fl->fl6_dst); 796 goto out2;
744 797
745 dst_release(&rt->dst); 798 dst_release(&rt->dst);
746 rt = nrt ? : net->ipv6.ip6_null_entry; 799 rt = nrt ? : net->ipv6.ip6_null_entry;
@@ -777,9 +830,9 @@ out2:
777} 830}
778 831
779static struct rt6_info *ip6_pol_route_input(struct net *net, struct fib6_table *table, 832static struct rt6_info *ip6_pol_route_input(struct net *net, struct fib6_table *table,
780 struct flowi *fl, int flags) 833 struct flowi6 *fl6, int flags)
781{ 834{
782 return ip6_pol_route(net, table, fl->iif, fl, flags); 835 return ip6_pol_route(net, table, fl6->flowi6_iif, fl6, flags);
783} 836}
784 837
785void ip6_route_input(struct sk_buff *skb) 838void ip6_route_input(struct sk_buff *skb)
@@ -787,56 +840,54 @@ void ip6_route_input(struct sk_buff *skb)
787 struct ipv6hdr *iph = ipv6_hdr(skb); 840 struct ipv6hdr *iph = ipv6_hdr(skb);
788 struct net *net = dev_net(skb->dev); 841 struct net *net = dev_net(skb->dev);
789 int flags = RT6_LOOKUP_F_HAS_SADDR; 842 int flags = RT6_LOOKUP_F_HAS_SADDR;
790 struct flowi fl = { 843 struct flowi6 fl6 = {
791 .iif = skb->dev->ifindex, 844 .flowi6_iif = skb->dev->ifindex,
792 .fl6_dst = iph->daddr, 845 .daddr = iph->daddr,
793 .fl6_src = iph->saddr, 846 .saddr = iph->saddr,
794 .fl6_flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK, 847 .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
795 .mark = skb->mark, 848 .flowi6_mark = skb->mark,
796 .proto = iph->nexthdr, 849 .flowi6_proto = iph->nexthdr,
797 }; 850 };
798 851
799 if (rt6_need_strict(&iph->daddr) && skb->dev->type != ARPHRD_PIMREG) 852 if (rt6_need_strict(&iph->daddr) && skb->dev->type != ARPHRD_PIMREG)
800 flags |= RT6_LOOKUP_F_IFACE; 853 flags |= RT6_LOOKUP_F_IFACE;
801 854
802 skb_dst_set(skb, fib6_rule_lookup(net, &fl, flags, ip6_pol_route_input)); 855 skb_dst_set(skb, fib6_rule_lookup(net, &fl6, flags, ip6_pol_route_input));
803} 856}
804 857
805static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table *table, 858static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table *table,
806 struct flowi *fl, int flags) 859 struct flowi6 *fl6, int flags)
807{ 860{
808 return ip6_pol_route(net, table, fl->oif, fl, flags); 861 return ip6_pol_route(net, table, fl6->flowi6_oif, fl6, flags);
809} 862}
810 863
811struct dst_entry * ip6_route_output(struct net *net, struct sock *sk, 864struct dst_entry * ip6_route_output(struct net *net, const struct sock *sk,
812 struct flowi *fl) 865 struct flowi6 *fl6)
813{ 866{
814 int flags = 0; 867 int flags = 0;
815 868
816 if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl->fl6_dst)) 869 if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr))
817 flags |= RT6_LOOKUP_F_IFACE; 870 flags |= RT6_LOOKUP_F_IFACE;
818 871
819 if (!ipv6_addr_any(&fl->fl6_src)) 872 if (!ipv6_addr_any(&fl6->saddr))
820 flags |= RT6_LOOKUP_F_HAS_SADDR; 873 flags |= RT6_LOOKUP_F_HAS_SADDR;
821 else if (sk) 874 else if (sk)
822 flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs); 875 flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs);
823 876
824 return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output); 877 return fib6_rule_lookup(net, fl6, flags, ip6_pol_route_output);
825} 878}
826 879
827EXPORT_SYMBOL(ip6_route_output); 880EXPORT_SYMBOL(ip6_route_output);
828 881
829int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl) 882struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig)
830{ 883{
831 struct rt6_info *ort = (struct rt6_info *) *dstp; 884 struct rt6_info *rt = dst_alloc(&ip6_dst_blackhole_ops, 1);
832 struct rt6_info *rt = (struct rt6_info *) 885 struct rt6_info *ort = (struct rt6_info *) dst_orig;
833 dst_alloc(&ip6_dst_blackhole_ops);
834 struct dst_entry *new = NULL; 886 struct dst_entry *new = NULL;
835 887
836 if (rt) { 888 if (rt) {
837 new = &rt->dst; 889 new = &rt->dst;
838 890
839 atomic_set(&new->__refcnt, 1);
840 new->__use = 1; 891 new->__use = 1;
841 new->input = dst_discard; 892 new->input = dst_discard;
842 new->output = dst_discard; 893 new->output = dst_discard;
@@ -862,11 +913,9 @@ int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl
862 dst_free(new); 913 dst_free(new);
863 } 914 }
864 915
865 dst_release(*dstp); 916 dst_release(dst_orig);
866 *dstp = new; 917 return new ? new : ERR_PTR(-ENOMEM);
867 return new ? 0 : -ENOMEM;
868} 918}
869EXPORT_SYMBOL_GPL(ip6_dst_blackhole);
870 919
871/* 920/*
872 * Destination cache support functions 921 * Destination cache support functions
@@ -878,9 +927,14 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
878 927
879 rt = (struct rt6_info *) dst; 928 rt = (struct rt6_info *) dst;
880 929
881 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) 930 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) {
931 if (rt->rt6i_peer_genid != rt6_peer_genid()) {
932 if (!rt->rt6i_peer)
933 rt6_bind_peer(rt, 0);
934 rt->rt6i_peer_genid = rt6_peer_genid();
935 }
882 return dst; 936 return dst;
883 937 }
884 return NULL; 938 return NULL;
885} 939}
886 940
@@ -931,7 +985,6 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
931 dst_metric_set(dst, RTAX_FEATURES, features); 985 dst_metric_set(dst, RTAX_FEATURES, features);
932 } 986 }
933 dst_metric_set(dst, RTAX_MTU, mtu); 987 dst_metric_set(dst, RTAX_MTU, mtu);
934 call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst);
935 } 988 }
936} 989}
937 990
@@ -1028,11 +1081,9 @@ out:
1028 1081
1029int icmp6_dst_gc(void) 1082int icmp6_dst_gc(void)
1030{ 1083{
1031 struct dst_entry *dst, *next, **pprev; 1084 struct dst_entry *dst, **pprev;
1032 int more = 0; 1085 int more = 0;
1033 1086
1034 next = NULL;
1035
1036 spin_lock_bh(&icmp6_dst_lock); 1087 spin_lock_bh(&icmp6_dst_lock);
1037 pprev = &icmp6_dst_gc_list; 1088 pprev = &icmp6_dst_gc_list;
1038 1089
@@ -1400,16 +1451,16 @@ static int ip6_route_del(struct fib6_config *cfg)
1400 * Handle redirects 1451 * Handle redirects
1401 */ 1452 */
1402struct ip6rd_flowi { 1453struct ip6rd_flowi {
1403 struct flowi fl; 1454 struct flowi6 fl6;
1404 struct in6_addr gateway; 1455 struct in6_addr gateway;
1405}; 1456};
1406 1457
1407static struct rt6_info *__ip6_route_redirect(struct net *net, 1458static struct rt6_info *__ip6_route_redirect(struct net *net,
1408 struct fib6_table *table, 1459 struct fib6_table *table,
1409 struct flowi *fl, 1460 struct flowi6 *fl6,
1410 int flags) 1461 int flags)
1411{ 1462{
1412 struct ip6rd_flowi *rdfl = (struct ip6rd_flowi *)fl; 1463 struct ip6rd_flowi *rdfl = (struct ip6rd_flowi *)fl6;
1413 struct rt6_info *rt; 1464 struct rt6_info *rt;
1414 struct fib6_node *fn; 1465 struct fib6_node *fn;
1415 1466
@@ -1425,7 +1476,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
1425 */ 1476 */
1426 1477
1427 read_lock_bh(&table->tb6_lock); 1478 read_lock_bh(&table->tb6_lock);
1428 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); 1479 fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
1429restart: 1480restart:
1430 for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) { 1481 for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) {
1431 /* 1482 /*
@@ -1440,7 +1491,7 @@ restart:
1440 continue; 1491 continue;
1441 if (!(rt->rt6i_flags & RTF_GATEWAY)) 1492 if (!(rt->rt6i_flags & RTF_GATEWAY))
1442 continue; 1493 continue;
1443 if (fl->oif != rt->rt6i_dev->ifindex) 1494 if (fl6->flowi6_oif != rt->rt6i_dev->ifindex)
1444 continue; 1495 continue;
1445 if (!ipv6_addr_equal(&rdfl->gateway, &rt->rt6i_gateway)) 1496 if (!ipv6_addr_equal(&rdfl->gateway, &rt->rt6i_gateway))
1446 continue; 1497 continue;
@@ -1449,7 +1500,7 @@ restart:
1449 1500
1450 if (!rt) 1501 if (!rt)
1451 rt = net->ipv6.ip6_null_entry; 1502 rt = net->ipv6.ip6_null_entry;
1452 BACKTRACK(net, &fl->fl6_src); 1503 BACKTRACK(net, &fl6->saddr);
1453out: 1504out:
1454 dst_hold(&rt->dst); 1505 dst_hold(&rt->dst);
1455 1506
@@ -1466,10 +1517,10 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest,
1466 int flags = RT6_LOOKUP_F_HAS_SADDR; 1517 int flags = RT6_LOOKUP_F_HAS_SADDR;
1467 struct net *net = dev_net(dev); 1518 struct net *net = dev_net(dev);
1468 struct ip6rd_flowi rdfl = { 1519 struct ip6rd_flowi rdfl = {
1469 .fl = { 1520 .fl6 = {
1470 .oif = dev->ifindex, 1521 .flowi6_oif = dev->ifindex,
1471 .fl6_dst = *dest, 1522 .daddr = *dest,
1472 .fl6_src = *src, 1523 .saddr = *src,
1473 }, 1524 },
1474 }; 1525 };
1475 1526
@@ -1478,7 +1529,7 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest,
1478 if (rt6_need_strict(dest)) 1529 if (rt6_need_strict(dest))
1479 flags |= RT6_LOOKUP_F_IFACE; 1530 flags |= RT6_LOOKUP_F_IFACE;
1480 1531
1481 return (struct rt6_info *)fib6_rule_lookup(net, (struct flowi *)&rdfl, 1532 return (struct rt6_info *)fib6_rule_lookup(net, &rdfl.fl6,
1482 flags, __ip6_route_redirect); 1533 flags, __ip6_route_redirect);
1483} 1534}
1484 1535
@@ -1968,7 +2019,6 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
1968 rt->dst.output = ip6_output; 2019 rt->dst.output = ip6_output;
1969 rt->rt6i_dev = net->loopback_dev; 2020 rt->rt6i_dev = net->loopback_dev;
1970 rt->rt6i_idev = idev; 2021 rt->rt6i_idev = idev;
1971 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, -1);
1972 rt->dst.obsolete = -1; 2022 rt->dst.obsolete = -1;
1973 2023
1974 rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; 2024 rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
@@ -1980,12 +2030,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
1980 if (IS_ERR(neigh)) { 2030 if (IS_ERR(neigh)) {
1981 dst_free(&rt->dst); 2031 dst_free(&rt->dst);
1982 2032
1983 /* We are casting this because that is the return 2033 return ERR_CAST(neigh);
1984 * value type. But an errno encoded pointer is the
1985 * same regardless of the underlying pointer type,
1986 * and that's what we are returning. So this is OK.
1987 */
1988 return (struct rt6_info *) neigh;
1989 } 2034 }
1990 rt->rt6i_nexthop = neigh; 2035 rt->rt6i_nexthop = neigh;
1991 2036
@@ -2346,7 +2391,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2346 struct rt6_info *rt; 2391 struct rt6_info *rt;
2347 struct sk_buff *skb; 2392 struct sk_buff *skb;
2348 struct rtmsg *rtm; 2393 struct rtmsg *rtm;
2349 struct flowi fl; 2394 struct flowi6 fl6;
2350 int err, iif = 0; 2395 int err, iif = 0;
2351 2396
2352 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy); 2397 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy);
@@ -2354,27 +2399,27 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2354 goto errout; 2399 goto errout;
2355 2400
2356 err = -EINVAL; 2401 err = -EINVAL;
2357 memset(&fl, 0, sizeof(fl)); 2402 memset(&fl6, 0, sizeof(fl6));
2358 2403
2359 if (tb[RTA_SRC]) { 2404 if (tb[RTA_SRC]) {
2360 if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr)) 2405 if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr))
2361 goto errout; 2406 goto errout;
2362 2407
2363 ipv6_addr_copy(&fl.fl6_src, nla_data(tb[RTA_SRC])); 2408 ipv6_addr_copy(&fl6.saddr, nla_data(tb[RTA_SRC]));
2364 } 2409 }
2365 2410
2366 if (tb[RTA_DST]) { 2411 if (tb[RTA_DST]) {
2367 if (nla_len(tb[RTA_DST]) < sizeof(struct in6_addr)) 2412 if (nla_len(tb[RTA_DST]) < sizeof(struct in6_addr))
2368 goto errout; 2413 goto errout;
2369 2414
2370 ipv6_addr_copy(&fl.fl6_dst, nla_data(tb[RTA_DST])); 2415 ipv6_addr_copy(&fl6.daddr, nla_data(tb[RTA_DST]));
2371 } 2416 }
2372 2417
2373 if (tb[RTA_IIF]) 2418 if (tb[RTA_IIF])
2374 iif = nla_get_u32(tb[RTA_IIF]); 2419 iif = nla_get_u32(tb[RTA_IIF]);
2375 2420
2376 if (tb[RTA_OIF]) 2421 if (tb[RTA_OIF])
2377 fl.oif = nla_get_u32(tb[RTA_OIF]); 2422 fl6.flowi6_oif = nla_get_u32(tb[RTA_OIF]);
2378 2423
2379 if (iif) { 2424 if (iif) {
2380 struct net_device *dev; 2425 struct net_device *dev;
@@ -2397,10 +2442,10 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2397 skb_reset_mac_header(skb); 2442 skb_reset_mac_header(skb);
2398 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr)); 2443 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr));
2399 2444
2400 rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); 2445 rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl6);
2401 skb_dst_set(skb, &rt->dst); 2446 skb_dst_set(skb, &rt->dst);
2402 2447
2403 err = rt6_fill_node(net, skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, 2448 err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif,
2404 RTM_NEWROUTE, NETLINK_CB(in_skb).pid, 2449 RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
2405 nlh->nlmsg_seq, 0, 0, 0); 2450 nlh->nlmsg_seq, 0, 0, 0);
2406 if (err < 0) { 2451 if (err < 0) {
@@ -2557,14 +2602,16 @@ static
2557int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, 2602int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write,
2558 void __user *buffer, size_t *lenp, loff_t *ppos) 2603 void __user *buffer, size_t *lenp, loff_t *ppos)
2559{ 2604{
2560 struct net *net = current->nsproxy->net_ns; 2605 struct net *net;
2561 int delay = net->ipv6.sysctl.flush_delay; 2606 int delay;
2562 if (write) { 2607 if (!write)
2563 proc_dointvec(ctl, write, buffer, lenp, ppos);
2564 fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
2565 return 0;
2566 } else
2567 return -EINVAL; 2608 return -EINVAL;
2609
2610 net = (struct net *)ctl->extra1;
2611 delay = net->ipv6.sysctl.flush_delay;
2612 proc_dointvec(ctl, write, buffer, lenp, ppos);
2613 fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
2614 return 0;
2568} 2615}
2569 2616
2570ctl_table ipv6_route_table_template[] = { 2617ctl_table ipv6_route_table_template[] = {
@@ -2651,6 +2698,7 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
2651 2698
2652 if (table) { 2699 if (table) {
2653 table[0].data = &net->ipv6.sysctl.flush_delay; 2700 table[0].data = &net->ipv6.sysctl.flush_delay;
2701 table[0].extra1 = net;
2654 table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh; 2702 table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh;
2655 table[2].data = &net->ipv6.sysctl.ip6_rt_max_size; 2703 table[2].data = &net->ipv6.sysctl.ip6_rt_max_size;
2656 table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; 2704 table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
@@ -2684,7 +2732,8 @@ static int __net_init ip6_route_net_init(struct net *net)
2684 net->ipv6.ip6_null_entry->dst.path = 2732 net->ipv6.ip6_null_entry->dst.path =
2685 (struct dst_entry *)net->ipv6.ip6_null_entry; 2733 (struct dst_entry *)net->ipv6.ip6_null_entry;
2686 net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops; 2734 net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops;
2687 dst_metric_set(&net->ipv6.ip6_null_entry->dst, RTAX_HOPLIMIT, 255); 2735 dst_init_metrics(&net->ipv6.ip6_null_entry->dst,
2736 ip6_template_metrics, true);
2688 2737
2689#ifdef CONFIG_IPV6_MULTIPLE_TABLES 2738#ifdef CONFIG_IPV6_MULTIPLE_TABLES
2690 net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, 2739 net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template,
@@ -2695,7 +2744,8 @@ static int __net_init ip6_route_net_init(struct net *net)
2695 net->ipv6.ip6_prohibit_entry->dst.path = 2744 net->ipv6.ip6_prohibit_entry->dst.path =
2696 (struct dst_entry *)net->ipv6.ip6_prohibit_entry; 2745 (struct dst_entry *)net->ipv6.ip6_prohibit_entry;
2697 net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops; 2746 net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops;
2698 dst_metric_set(&net->ipv6.ip6_prohibit_entry->dst, RTAX_HOPLIMIT, 255); 2747 dst_init_metrics(&net->ipv6.ip6_prohibit_entry->dst,
2748 ip6_template_metrics, true);
2699 2749
2700 net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, 2750 net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template,
2701 sizeof(*net->ipv6.ip6_blk_hole_entry), 2751 sizeof(*net->ipv6.ip6_blk_hole_entry),
@@ -2705,7 +2755,8 @@ static int __net_init ip6_route_net_init(struct net *net)
2705 net->ipv6.ip6_blk_hole_entry->dst.path = 2755 net->ipv6.ip6_blk_hole_entry->dst.path =
2706 (struct dst_entry *)net->ipv6.ip6_blk_hole_entry; 2756 (struct dst_entry *)net->ipv6.ip6_blk_hole_entry;
2707 net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; 2757 net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops;
2708 dst_metric_set(&net->ipv6.ip6_blk_hole_entry->dst, RTAX_HOPLIMIT, 255); 2758 dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst,
2759 ip6_template_metrics, true);
2709#endif 2760#endif
2710 2761
2711 net->ipv6.sysctl.flush_delay = 0; 2762 net->ipv6.sysctl.flush_delay = 0;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 8ce38f10a547..43b33373adb2 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -412,7 +412,7 @@ static void prl_list_destroy_rcu(struct rcu_head *head)
412 412
413 p = container_of(head, struct ip_tunnel_prl_entry, rcu_head); 413 p = container_of(head, struct ip_tunnel_prl_entry, rcu_head);
414 do { 414 do {
415 n = p->next; 415 n = rcu_dereference_protected(p->next, 1);
416 kfree(p); 416 kfree(p);
417 p = n; 417 p = n;
418 } while (p); 418 } while (p);
@@ -421,15 +421,17 @@ static void prl_list_destroy_rcu(struct rcu_head *head)
421static int 421static int
422ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) 422ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
423{ 423{
424 struct ip_tunnel_prl_entry *x, **p; 424 struct ip_tunnel_prl_entry *x;
425 struct ip_tunnel_prl_entry __rcu **p;
425 int err = 0; 426 int err = 0;
426 427
427 ASSERT_RTNL(); 428 ASSERT_RTNL();
428 429
429 if (a && a->addr != htonl(INADDR_ANY)) { 430 if (a && a->addr != htonl(INADDR_ANY)) {
430 for (p = &t->prl; *p; p = &(*p)->next) { 431 for (p = &t->prl;
431 if ((*p)->addr == a->addr) { 432 (x = rtnl_dereference(*p)) != NULL;
432 x = *p; 433 p = &x->next) {
434 if (x->addr == a->addr) {
433 *p = x->next; 435 *p = x->next;
434 call_rcu(&x->rcu_head, prl_entry_destroy_rcu); 436 call_rcu(&x->rcu_head, prl_entry_destroy_rcu);
435 t->prl_count--; 437 t->prl_count--;
@@ -438,9 +440,9 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
438 } 440 }
439 err = -ENXIO; 441 err = -ENXIO;
440 } else { 442 } else {
441 if (t->prl) { 443 x = rtnl_dereference(t->prl);
444 if (x) {
442 t->prl_count = 0; 445 t->prl_count = 0;
443 x = t->prl;
444 call_rcu(&x->rcu_head, prl_list_destroy_rcu); 446 call_rcu(&x->rcu_head, prl_list_destroy_rcu);
445 t->prl = NULL; 447 t->prl = NULL;
446 } 448 }
@@ -730,16 +732,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
730 dst = addr6->s6_addr32[3]; 732 dst = addr6->s6_addr32[3];
731 } 733 }
732 734
733 { 735 rt = ip_route_output_ports(dev_net(dev), NULL,
734 struct flowi fl = { .fl4_dst = dst, 736 dst, tiph->saddr,
735 .fl4_src = tiph->saddr, 737 0, 0,
736 .fl4_tos = RT_TOS(tos), 738 IPPROTO_IPV6, RT_TOS(tos),
737 .oif = tunnel->parms.link, 739 tunnel->parms.link);
738 .proto = IPPROTO_IPV6 }; 740 if (IS_ERR(rt)) {
739 if (ip_route_output_key(dev_net(dev), &rt, &fl)) { 741 dev->stats.tx_carrier_errors++;
740 dev->stats.tx_carrier_errors++; 742 goto tx_error_icmp;
741 goto tx_error_icmp;
742 }
743 } 743 }
744 if (rt->rt_type != RTN_UNICAST) { 744 if (rt->rt_type != RTN_UNICAST) {
745 ip_rt_put(rt); 745 ip_rt_put(rt);
@@ -855,13 +855,14 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
855 iph = &tunnel->parms.iph; 855 iph = &tunnel->parms.iph;
856 856
857 if (iph->daddr) { 857 if (iph->daddr) {
858 struct flowi fl = { .fl4_dst = iph->daddr, 858 struct rtable *rt = ip_route_output_ports(dev_net(dev), NULL,
859 .fl4_src = iph->saddr, 859 iph->daddr, iph->saddr,
860 .fl4_tos = RT_TOS(iph->tos), 860 0, 0,
861 .oif = tunnel->parms.link, 861 IPPROTO_IPV6,
862 .proto = IPPROTO_IPV6 }; 862 RT_TOS(iph->tos),
863 struct rtable *rt; 863 tunnel->parms.link);
864 if (!ip_route_output_key(dev_net(dev), &rt, &fl)) { 864
865 if (!IS_ERR(rt)) {
865 tdev = rt->dst.dev; 866 tdev = rt->dst.dev;
866 ip_rt_put(rt); 867 ip_rt_put(rt);
867 } 868 }
@@ -1179,7 +1180,7 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
1179 if (!dev->tstats) 1180 if (!dev->tstats)
1180 return -ENOMEM; 1181 return -ENOMEM;
1181 dev_hold(dev); 1182 dev_hold(dev);
1182 sitn->tunnels_wc[0] = tunnel; 1183 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1183 return 0; 1184 return 0;
1184} 1185}
1185 1186
@@ -1196,11 +1197,12 @@ static void __net_exit sit_destroy_tunnels(struct sit_net *sitn, struct list_hea
1196 for (prio = 1; prio < 4; prio++) { 1197 for (prio = 1; prio < 4; prio++) {
1197 int h; 1198 int h;
1198 for (h = 0; h < HASH_SIZE; h++) { 1199 for (h = 0; h < HASH_SIZE; h++) {
1199 struct ip_tunnel *t = sitn->tunnels[prio][h]; 1200 struct ip_tunnel *t;
1200 1201
1202 t = rtnl_dereference(sitn->tunnels[prio][h]);
1201 while (t != NULL) { 1203 while (t != NULL) {
1202 unregister_netdevice_queue(t->dev, head); 1204 unregister_netdevice_queue(t->dev, head);
1203 t = t->next; 1205 t = rtnl_dereference(t->next);
1204 } 1206 }
1205 } 1207 }
1206 } 1208 }
@@ -1290,4 +1292,4 @@ static int __init sit_init(void)
1290module_init(sit_init); 1292module_init(sit_init);
1291module_exit(sit_cleanup); 1293module_exit(sit_cleanup);
1292MODULE_LICENSE("GPL"); 1294MODULE_LICENSE("GPL");
1293MODULE_ALIAS("sit0"); 1295MODULE_ALIAS_NETDEV("sit0");
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 09fd34f0dbf2..352c26081f5d 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -232,23 +232,20 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
232 */ 232 */
233 { 233 {
234 struct in6_addr *final_p, final; 234 struct in6_addr *final_p, final;
235 struct flowi fl; 235 struct flowi6 fl6;
236 memset(&fl, 0, sizeof(fl)); 236 memset(&fl6, 0, sizeof(fl6));
237 fl.proto = IPPROTO_TCP; 237 fl6.flowi6_proto = IPPROTO_TCP;
238 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); 238 ipv6_addr_copy(&fl6.daddr, &ireq6->rmt_addr);
239 final_p = fl6_update_dst(&fl, np->opt, &final); 239 final_p = fl6_update_dst(&fl6, np->opt, &final);
240 ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr); 240 ipv6_addr_copy(&fl6.saddr, &ireq6->loc_addr);
241 fl.oif = sk->sk_bound_dev_if; 241 fl6.flowi6_oif = sk->sk_bound_dev_if;
242 fl.mark = sk->sk_mark; 242 fl6.flowi6_mark = sk->sk_mark;
243 fl.fl_ip_dport = inet_rsk(req)->rmt_port; 243 fl6.fl6_dport = inet_rsk(req)->rmt_port;
244 fl.fl_ip_sport = inet_sk(sk)->inet_sport; 244 fl6.fl6_sport = inet_sk(sk)->inet_sport;
245 security_req_classify_flow(req, &fl); 245 security_req_classify_flow(req, flowi6_to_flowi(&fl6));
246 if (ip6_dst_lookup(sk, &dst, &fl)) 246
247 goto out_free; 247 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
248 248 if (IS_ERR(dst))
249 if (final_p)
250 ipv6_addr_copy(&fl.fl6_dst, final_p);
251 if ((xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0)
252 goto out_free; 249 goto out_free;
253 } 250 }
254 251
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 7cb65ef79f9c..6dcf5e7d661b 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -17,6 +17,16 @@
17 17
18static struct ctl_table empty[1]; 18static struct ctl_table empty[1];
19 19
20static ctl_table ipv6_static_skeleton[] = {
21 {
22 .procname = "neigh",
23 .maxlen = 0,
24 .mode = 0555,
25 .child = empty,
26 },
27 { }
28};
29
20static ctl_table ipv6_table_template[] = { 30static ctl_table ipv6_table_template[] = {
21 { 31 {
22 .procname = "route", 32 .procname = "route",
@@ -37,12 +47,6 @@ static ctl_table ipv6_table_template[] = {
37 .mode = 0644, 47 .mode = 0644,
38 .proc_handler = proc_dointvec 48 .proc_handler = proc_dointvec
39 }, 49 },
40 {
41 .procname = "neigh",
42 .maxlen = 0,
43 .mode = 0555,
44 .child = empty,
45 },
46 { } 50 { }
47}; 51};
48 52
@@ -160,7 +164,7 @@ static struct ctl_table_header *ip6_base;
160 164
161int ipv6_static_sysctl_register(void) 165int ipv6_static_sysctl_register(void)
162{ 166{
163 ip6_base = register_sysctl_paths(net_ipv6_ctl_path, empty); 167 ip6_base = register_sysctl_paths(net_ipv6_ctl_path, ipv6_static_skeleton);
164 if (ip6_base == NULL) 168 if (ip6_base == NULL)
165 return -ENOMEM; 169 return -ENOMEM;
166 return 0; 170 return 0;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 20aa95e37359..4f49e5dd41bb 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -131,7 +131,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
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 rt6_info *rt;
134 struct flowi fl; 134 struct flowi6 fl6;
135 struct dst_entry *dst; 135 struct dst_entry *dst;
136 int addr_type; 136 int addr_type;
137 int err; 137 int err;
@@ -142,14 +142,14 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
142 if (usin->sin6_family != AF_INET6) 142 if (usin->sin6_family != AF_INET6)
143 return -EAFNOSUPPORT; 143 return -EAFNOSUPPORT;
144 144
145 memset(&fl, 0, sizeof(fl)); 145 memset(&fl6, 0, sizeof(fl6));
146 146
147 if (np->sndflow) { 147 if (np->sndflow) {
148 fl.fl6_flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK; 148 fl6.flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK;
149 IP6_ECN_flow_init(fl.fl6_flowlabel); 149 IP6_ECN_flow_init(fl6.flowlabel);
150 if (fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) { 150 if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {
151 struct ip6_flowlabel *flowlabel; 151 struct ip6_flowlabel *flowlabel;
152 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); 152 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
153 if (flowlabel == NULL) 153 if (flowlabel == NULL)
154 return -EINVAL; 154 return -EINVAL;
155 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst); 155 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst);
@@ -195,7 +195,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
195 } 195 }
196 196
197 ipv6_addr_copy(&np->daddr, &usin->sin6_addr); 197 ipv6_addr_copy(&np->daddr, &usin->sin6_addr);
198 np->flow_label = fl.fl6_flowlabel; 198 np->flow_label = fl6.flowlabel;
199 199
200 /* 200 /*
201 * TCP over IPv4 201 * TCP over IPv4
@@ -242,35 +242,27 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
242 if (!ipv6_addr_any(&np->rcv_saddr)) 242 if (!ipv6_addr_any(&np->rcv_saddr))
243 saddr = &np->rcv_saddr; 243 saddr = &np->rcv_saddr;
244 244
245 fl.proto = IPPROTO_TCP; 245 fl6.flowi6_proto = IPPROTO_TCP;
246 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 246 ipv6_addr_copy(&fl6.daddr, &np->daddr);
247 ipv6_addr_copy(&fl.fl6_src, 247 ipv6_addr_copy(&fl6.saddr,
248 (saddr ? saddr : &np->saddr)); 248 (saddr ? saddr : &np->saddr));
249 fl.oif = sk->sk_bound_dev_if; 249 fl6.flowi6_oif = sk->sk_bound_dev_if;
250 fl.mark = sk->sk_mark; 250 fl6.flowi6_mark = sk->sk_mark;
251 fl.fl_ip_dport = usin->sin6_port; 251 fl6.fl6_dport = usin->sin6_port;
252 fl.fl_ip_sport = inet->inet_sport; 252 fl6.fl6_sport = inet->inet_sport;
253 253
254 final_p = fl6_update_dst(&fl, np->opt, &final); 254 final_p = fl6_update_dst(&fl6, np->opt, &final);
255 255
256 security_sk_classify_flow(sk, &fl); 256 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
257 257
258 err = ip6_dst_lookup(sk, &dst, &fl); 258 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
259 if (err) 259 if (IS_ERR(dst)) {
260 err = PTR_ERR(dst);
260 goto failure; 261 goto failure;
261 if (final_p)
262 ipv6_addr_copy(&fl.fl6_dst, final_p);
263
264 err = __xfrm_lookup(sock_net(sk), &dst, &fl, sk, XFRM_LOOKUP_WAIT);
265 if (err < 0) {
266 if (err == -EREMOTE)
267 err = ip6_dst_blackhole(sk, &dst, &fl);
268 if (err < 0)
269 goto failure;
270 } 262 }
271 263
272 if (saddr == NULL) { 264 if (saddr == NULL) {
273 saddr = &fl.fl6_src; 265 saddr = &fl6.saddr;
274 ipv6_addr_copy(&np->rcv_saddr, saddr); 266 ipv6_addr_copy(&np->rcv_saddr, saddr);
275 } 267 }
276 268
@@ -385,7 +377,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
385 np = inet6_sk(sk); 377 np = inet6_sk(sk);
386 378
387 if (type == ICMPV6_PKT_TOOBIG) { 379 if (type == ICMPV6_PKT_TOOBIG) {
388 struct dst_entry *dst = NULL; 380 struct dst_entry *dst;
389 381
390 if (sock_owned_by_user(sk)) 382 if (sock_owned_by_user(sk))
391 goto out; 383 goto out;
@@ -397,29 +389,25 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
397 389
398 if (dst == NULL) { 390 if (dst == NULL) {
399 struct inet_sock *inet = inet_sk(sk); 391 struct inet_sock *inet = inet_sk(sk);
400 struct flowi fl; 392 struct flowi6 fl6;
401 393
402 /* BUGGG_FUTURE: Again, it is not clear how 394 /* BUGGG_FUTURE: Again, it is not clear how
403 to handle rthdr case. Ignore this complexity 395 to handle rthdr case. Ignore this complexity
404 for now. 396 for now.
405 */ 397 */
406 memset(&fl, 0, sizeof(fl)); 398 memset(&fl6, 0, sizeof(fl6));
407 fl.proto = IPPROTO_TCP; 399 fl6.flowi6_proto = IPPROTO_TCP;
408 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 400 ipv6_addr_copy(&fl6.daddr, &np->daddr);
409 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 401 ipv6_addr_copy(&fl6.saddr, &np->saddr);
410 fl.oif = sk->sk_bound_dev_if; 402 fl6.flowi6_oif = sk->sk_bound_dev_if;
411 fl.mark = sk->sk_mark; 403 fl6.flowi6_mark = sk->sk_mark;
412 fl.fl_ip_dport = inet->inet_dport; 404 fl6.fl6_dport = inet->inet_dport;
413 fl.fl_ip_sport = inet->inet_sport; 405 fl6.fl6_sport = inet->inet_sport;
414 security_skb_classify_flow(skb, &fl); 406 security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));
415 407
416 if ((err = ip6_dst_lookup(sk, &dst, &fl))) { 408 dst = ip6_dst_lookup_flow(sk, &fl6, NULL, false);
417 sk->sk_err_soft = -err; 409 if (IS_ERR(dst)) {
418 goto out; 410 sk->sk_err_soft = -PTR_ERR(dst);
419 }
420
421 if ((err = xfrm_lookup(net, &dst, &fl, sk, 0)) < 0) {
422 sk->sk_err_soft = -err;
423 goto out; 411 goto out;
424 } 412 }
425 413
@@ -494,38 +482,37 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
494 struct sk_buff * skb; 482 struct sk_buff * skb;
495 struct ipv6_txoptions *opt = NULL; 483 struct ipv6_txoptions *opt = NULL;
496 struct in6_addr * final_p, final; 484 struct in6_addr * final_p, final;
497 struct flowi fl; 485 struct flowi6 fl6;
498 struct dst_entry *dst; 486 struct dst_entry *dst;
499 int err = -1; 487 int err;
500 488
501 memset(&fl, 0, sizeof(fl)); 489 memset(&fl6, 0, sizeof(fl6));
502 fl.proto = IPPROTO_TCP; 490 fl6.flowi6_proto = IPPROTO_TCP;
503 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); 491 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr);
504 ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr); 492 ipv6_addr_copy(&fl6.saddr, &treq->loc_addr);
505 fl.fl6_flowlabel = 0; 493 fl6.flowlabel = 0;
506 fl.oif = treq->iif; 494 fl6.flowi6_oif = treq->iif;
507 fl.mark = sk->sk_mark; 495 fl6.flowi6_mark = sk->sk_mark;
508 fl.fl_ip_dport = inet_rsk(req)->rmt_port; 496 fl6.fl6_dport = inet_rsk(req)->rmt_port;
509 fl.fl_ip_sport = inet_rsk(req)->loc_port; 497 fl6.fl6_sport = inet_rsk(req)->loc_port;
510 security_req_classify_flow(req, &fl); 498 security_req_classify_flow(req, flowi6_to_flowi(&fl6));
511 499
512 opt = np->opt; 500 opt = np->opt;
513 final_p = fl6_update_dst(&fl, opt, &final); 501 final_p = fl6_update_dst(&fl6, opt, &final);
514 502
515 err = ip6_dst_lookup(sk, &dst, &fl); 503 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
516 if (err) 504 if (IS_ERR(dst)) {
505 err = PTR_ERR(dst);
506 dst = NULL;
517 goto done; 507 goto done;
518 if (final_p) 508 }
519 ipv6_addr_copy(&fl.fl6_dst, final_p);
520 if ((err = xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0)
521 goto done;
522
523 skb = tcp_make_synack(sk, dst, req, rvp); 509 skb = tcp_make_synack(sk, dst, req, rvp);
510 err = -ENOMEM;
524 if (skb) { 511 if (skb) {
525 __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr); 512 __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr);
526 513
527 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); 514 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr);
528 err = ip6_xmit(sk, skb, &fl, opt); 515 err = ip6_xmit(sk, skb, &fl6, opt);
529 err = net_xmit_eval(err); 516 err = net_xmit_eval(err);
530 } 517 }
531 518
@@ -1006,7 +993,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
1006{ 993{
1007 struct tcphdr *th = tcp_hdr(skb), *t1; 994 struct tcphdr *th = tcp_hdr(skb), *t1;
1008 struct sk_buff *buff; 995 struct sk_buff *buff;
1009 struct flowi fl; 996 struct flowi6 fl6;
1010 struct net *net = dev_net(skb_dst(skb)->dev); 997 struct net *net = dev_net(skb_dst(skb)->dev);
1011 struct sock *ctl_sk = net->ipv6.tcp_sk; 998 struct sock *ctl_sk = net->ipv6.tcp_sk;
1012 unsigned int tot_len = sizeof(struct tcphdr); 999 unsigned int tot_len = sizeof(struct tcphdr);
@@ -1060,34 +1047,33 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
1060 } 1047 }
1061#endif 1048#endif
1062 1049
1063 memset(&fl, 0, sizeof(fl)); 1050 memset(&fl6, 0, sizeof(fl6));
1064 ipv6_addr_copy(&fl.fl6_dst, &ipv6_hdr(skb)->saddr); 1051 ipv6_addr_copy(&fl6.daddr, &ipv6_hdr(skb)->saddr);
1065 ipv6_addr_copy(&fl.fl6_src, &ipv6_hdr(skb)->daddr); 1052 ipv6_addr_copy(&fl6.saddr, &ipv6_hdr(skb)->daddr);
1066 1053
1067 buff->ip_summed = CHECKSUM_PARTIAL; 1054 buff->ip_summed = CHECKSUM_PARTIAL;
1068 buff->csum = 0; 1055 buff->csum = 0;
1069 1056
1070 __tcp_v6_send_check(buff, &fl.fl6_src, &fl.fl6_dst); 1057 __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr);
1071 1058
1072 fl.proto = IPPROTO_TCP; 1059 fl6.flowi6_proto = IPPROTO_TCP;
1073 fl.oif = inet6_iif(skb); 1060 fl6.flowi6_oif = inet6_iif(skb);
1074 fl.fl_ip_dport = t1->dest; 1061 fl6.fl6_dport = t1->dest;
1075 fl.fl_ip_sport = t1->source; 1062 fl6.fl6_sport = t1->source;
1076 security_skb_classify_flow(skb, &fl); 1063 security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));
1077 1064
1078 /* Pass a socket to ip6_dst_lookup either it is for RST 1065 /* Pass a socket to ip6_dst_lookup either it is for RST
1079 * Underlying function will use this to retrieve the network 1066 * Underlying function will use this to retrieve the network
1080 * namespace 1067 * namespace
1081 */ 1068 */
1082 if (!ip6_dst_lookup(ctl_sk, &dst, &fl)) { 1069 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false);
1083 if (xfrm_lookup(net, &dst, &fl, NULL, 0) >= 0) { 1070 if (!IS_ERR(dst)) {
1084 skb_dst_set(buff, dst); 1071 skb_dst_set(buff, dst);
1085 ip6_xmit(ctl_sk, buff, &fl, NULL); 1072 ip6_xmit(ctl_sk, buff, &fl6, NULL);
1086 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); 1073 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
1087 if (rst) 1074 if (rst)
1088 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); 1075 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
1089 return; 1076 return;
1090 }
1091 } 1077 }
1092 1078
1093 kfree_skb(buff); 1079 kfree_skb(buff);
@@ -1323,7 +1309,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1323 tcp_death_row.sysctl_tw_recycle && 1309 tcp_death_row.sysctl_tw_recycle &&
1324 (dst = inet6_csk_route_req(sk, req)) != NULL && 1310 (dst = inet6_csk_route_req(sk, req)) != NULL &&
1325 (peer = rt6_get_peer((struct rt6_info *)dst)) != NULL && 1311 (peer = rt6_get_peer((struct rt6_info *)dst)) != NULL &&
1326 ipv6_addr_equal((struct in6_addr *)peer->daddr.a6, 1312 ipv6_addr_equal((struct in6_addr *)peer->daddr.addr.a6,
1327 &treq->rmt_addr)) { 1313 &treq->rmt_addr)) {
1328 inet_peer_refcheck(peer); 1314 inet_peer_refcheck(peer);
1329 if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && 1315 if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL &&
@@ -1636,10 +1622,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1636 opt_skb = skb_clone(skb, GFP_ATOMIC); 1622 opt_skb = skb_clone(skb, GFP_ATOMIC);
1637 1623
1638 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ 1624 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
1639 TCP_CHECK_TIMER(sk); 1625 sock_rps_save_rxhash(sk, skb->rxhash);
1640 if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) 1626 if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len))
1641 goto reset; 1627 goto reset;
1642 TCP_CHECK_TIMER(sk);
1643 if (opt_skb) 1628 if (opt_skb)
1644 goto ipv6_pktoptions; 1629 goto ipv6_pktoptions;
1645 return 0; 1630 return 0;
@@ -1665,12 +1650,11 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1665 __kfree_skb(opt_skb); 1650 __kfree_skb(opt_skb);
1666 return 0; 1651 return 0;
1667 } 1652 }
1668 } 1653 } else
1654 sock_rps_save_rxhash(sk, skb->rxhash);
1669 1655
1670 TCP_CHECK_TIMER(sk);
1671 if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len)) 1656 if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len))
1672 goto reset; 1657 goto reset;
1673 TCP_CHECK_TIMER(sk);
1674 if (opt_skb) 1658 if (opt_skb)
1675 goto ipv6_pktoptions; 1659 goto ipv6_pktoptions;
1676 return 0; 1660 return 0;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 9a009c66c8a3..9e305d74b3d4 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -505,6 +505,9 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
505 int rc; 505 int rc;
506 int is_udplite = IS_UDPLITE(sk); 506 int is_udplite = IS_UDPLITE(sk);
507 507
508 if (!ipv6_addr_any(&inet6_sk(sk)->daddr))
509 sock_rps_save_rxhash(sk, skb->rxhash);
510
508 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 511 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
509 goto drop; 512 goto drop;
510 513
@@ -886,7 +889,7 @@ static int udp_v6_push_pending_frames(struct sock *sk)
886 struct udphdr *uh; 889 struct udphdr *uh;
887 struct udp_sock *up = udp_sk(sk); 890 struct udp_sock *up = udp_sk(sk);
888 struct inet_sock *inet = inet_sk(sk); 891 struct inet_sock *inet = inet_sk(sk);
889 struct flowi *fl = &inet->cork.fl; 892 struct flowi6 *fl6 = &inet->cork.fl.u.ip6;
890 int err = 0; 893 int err = 0;
891 int is_udplite = IS_UDPLITE(sk); 894 int is_udplite = IS_UDPLITE(sk);
892 __wsum csum = 0; 895 __wsum csum = 0;
@@ -899,23 +902,23 @@ static int udp_v6_push_pending_frames(struct sock *sk)
899 * Create a UDP header 902 * Create a UDP header
900 */ 903 */
901 uh = udp_hdr(skb); 904 uh = udp_hdr(skb);
902 uh->source = fl->fl_ip_sport; 905 uh->source = fl6->fl6_sport;
903 uh->dest = fl->fl_ip_dport; 906 uh->dest = fl6->fl6_dport;
904 uh->len = htons(up->len); 907 uh->len = htons(up->len);
905 uh->check = 0; 908 uh->check = 0;
906 909
907 if (is_udplite) 910 if (is_udplite)
908 csum = udplite_csum_outgoing(sk, skb); 911 csum = udplite_csum_outgoing(sk, skb);
909 else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* UDP hardware csum */ 912 else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* UDP hardware csum */
910 udp6_hwcsum_outgoing(sk, skb, &fl->fl6_src, &fl->fl6_dst, 913 udp6_hwcsum_outgoing(sk, skb, &fl6->saddr, &fl6->daddr,
911 up->len); 914 up->len);
912 goto send; 915 goto send;
913 } else 916 } else
914 csum = udp_csum_outgoing(sk, skb); 917 csum = udp_csum_outgoing(sk, skb);
915 918
916 /* add protocol-dependent pseudo-header */ 919 /* add protocol-dependent pseudo-header */
917 uh->check = csum_ipv6_magic(&fl->fl6_src, &fl->fl6_dst, 920 uh->check = csum_ipv6_magic(&fl6->saddr, &fl6->daddr,
918 up->len, fl->proto, csum ); 921 up->len, fl6->flowi6_proto, csum);
919 if (uh->check == 0) 922 if (uh->check == 0)
920 uh->check = CSUM_MANGLED_0; 923 uh->check = CSUM_MANGLED_0;
921 924
@@ -947,7 +950,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
947 struct in6_addr *daddr, *final_p, final; 950 struct in6_addr *daddr, *final_p, final;
948 struct ipv6_txoptions *opt = NULL; 951 struct ipv6_txoptions *opt = NULL;
949 struct ip6_flowlabel *flowlabel = NULL; 952 struct ip6_flowlabel *flowlabel = NULL;
950 struct flowi fl; 953 struct flowi6 fl6;
951 struct dst_entry *dst; 954 struct dst_entry *dst;
952 int addr_len = msg->msg_namelen; 955 int addr_len = msg->msg_namelen;
953 int ulen = len; 956 int ulen = len;
@@ -1030,19 +1033,19 @@ do_udp_sendmsg:
1030 } 1033 }
1031 ulen += sizeof(struct udphdr); 1034 ulen += sizeof(struct udphdr);
1032 1035
1033 memset(&fl, 0, sizeof(fl)); 1036 memset(&fl6, 0, sizeof(fl6));
1034 1037
1035 if (sin6) { 1038 if (sin6) {
1036 if (sin6->sin6_port == 0) 1039 if (sin6->sin6_port == 0)
1037 return -EINVAL; 1040 return -EINVAL;
1038 1041
1039 fl.fl_ip_dport = sin6->sin6_port; 1042 fl6.fl6_dport = sin6->sin6_port;
1040 daddr = &sin6->sin6_addr; 1043 daddr = &sin6->sin6_addr;
1041 1044
1042 if (np->sndflow) { 1045 if (np->sndflow) {
1043 fl.fl6_flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK; 1046 fl6.flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK;
1044 if (fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) { 1047 if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {
1045 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); 1048 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
1046 if (flowlabel == NULL) 1049 if (flowlabel == NULL)
1047 return -EINVAL; 1050 return -EINVAL;
1048 daddr = &flowlabel->dst; 1051 daddr = &flowlabel->dst;
@@ -1060,38 +1063,38 @@ do_udp_sendmsg:
1060 if (addr_len >= sizeof(struct sockaddr_in6) && 1063 if (addr_len >= sizeof(struct sockaddr_in6) &&
1061 sin6->sin6_scope_id && 1064 sin6->sin6_scope_id &&
1062 ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL) 1065 ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
1063 fl.oif = sin6->sin6_scope_id; 1066 fl6.flowi6_oif = sin6->sin6_scope_id;
1064 } else { 1067 } else {
1065 if (sk->sk_state != TCP_ESTABLISHED) 1068 if (sk->sk_state != TCP_ESTABLISHED)
1066 return -EDESTADDRREQ; 1069 return -EDESTADDRREQ;
1067 1070
1068 fl.fl_ip_dport = inet->inet_dport; 1071 fl6.fl6_dport = inet->inet_dport;
1069 daddr = &np->daddr; 1072 daddr = &np->daddr;
1070 fl.fl6_flowlabel = np->flow_label; 1073 fl6.flowlabel = np->flow_label;
1071 connected = 1; 1074 connected = 1;
1072 } 1075 }
1073 1076
1074 if (!fl.oif) 1077 if (!fl6.flowi6_oif)
1075 fl.oif = sk->sk_bound_dev_if; 1078 fl6.flowi6_oif = sk->sk_bound_dev_if;
1076 1079
1077 if (!fl.oif) 1080 if (!fl6.flowi6_oif)
1078 fl.oif = np->sticky_pktinfo.ipi6_ifindex; 1081 fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex;
1079 1082
1080 fl.mark = sk->sk_mark; 1083 fl6.flowi6_mark = sk->sk_mark;
1081 1084
1082 if (msg->msg_controllen) { 1085 if (msg->msg_controllen) {
1083 opt = &opt_space; 1086 opt = &opt_space;
1084 memset(opt, 0, sizeof(struct ipv6_txoptions)); 1087 memset(opt, 0, sizeof(struct ipv6_txoptions));
1085 opt->tot_len = sizeof(*opt); 1088 opt->tot_len = sizeof(*opt);
1086 1089
1087 err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit, 1090 err = datagram_send_ctl(sock_net(sk), msg, &fl6, opt, &hlimit,
1088 &tclass, &dontfrag); 1091 &tclass, &dontfrag);
1089 if (err < 0) { 1092 if (err < 0) {
1090 fl6_sock_release(flowlabel); 1093 fl6_sock_release(flowlabel);
1091 return err; 1094 return err;
1092 } 1095 }
1093 if ((fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) { 1096 if ((fl6.flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) {
1094 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); 1097 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
1095 if (flowlabel == NULL) 1098 if (flowlabel == NULL)
1096 return -EINVAL; 1099 return -EINVAL;
1097 } 1100 }
@@ -1105,42 +1108,35 @@ do_udp_sendmsg:
1105 opt = fl6_merge_options(&opt_space, flowlabel, opt); 1108 opt = fl6_merge_options(&opt_space, flowlabel, opt);
1106 opt = ipv6_fixup_options(&opt_space, opt); 1109 opt = ipv6_fixup_options(&opt_space, opt);
1107 1110
1108 fl.proto = sk->sk_protocol; 1111 fl6.flowi6_proto = sk->sk_protocol;
1109 if (!ipv6_addr_any(daddr)) 1112 if (!ipv6_addr_any(daddr))
1110 ipv6_addr_copy(&fl.fl6_dst, daddr); 1113 ipv6_addr_copy(&fl6.daddr, daddr);
1111 else 1114 else
1112 fl.fl6_dst.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */ 1115 fl6.daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */
1113 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 1116 if (ipv6_addr_any(&fl6.saddr) && !ipv6_addr_any(&np->saddr))
1114 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 1117 ipv6_addr_copy(&fl6.saddr, &np->saddr);
1115 fl.fl_ip_sport = inet->inet_sport; 1118 fl6.fl6_sport = inet->inet_sport;
1116 1119
1117 final_p = fl6_update_dst(&fl, opt, &final); 1120 final_p = fl6_update_dst(&fl6, opt, &final);
1118 if (final_p) 1121 if (final_p)
1119 connected = 0; 1122 connected = 0;
1120 1123
1121 if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) { 1124 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) {
1122 fl.oif = np->mcast_oif; 1125 fl6.flowi6_oif = np->mcast_oif;
1123 connected = 0; 1126 connected = 0;
1124 } 1127 }
1125 1128
1126 security_sk_classify_flow(sk, &fl); 1129 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
1127 1130
1128 err = ip6_sk_dst_lookup(sk, &dst, &fl); 1131 dst = ip6_sk_dst_lookup_flow(sk, &fl6, final_p, true);
1129 if (err) 1132 if (IS_ERR(dst)) {
1133 err = PTR_ERR(dst);
1134 dst = NULL;
1130 goto out; 1135 goto out;
1131 if (final_p)
1132 ipv6_addr_copy(&fl.fl6_dst, final_p);
1133
1134 err = __xfrm_lookup(sock_net(sk), &dst, &fl, sk, XFRM_LOOKUP_WAIT);
1135 if (err < 0) {
1136 if (err == -EREMOTE)
1137 err = ip6_dst_blackhole(sk, &dst, &fl);
1138 if (err < 0)
1139 goto out;
1140 } 1136 }
1141 1137
1142 if (hlimit < 0) { 1138 if (hlimit < 0) {
1143 if (ipv6_addr_is_multicast(&fl.fl6_dst)) 1139 if (ipv6_addr_is_multicast(&fl6.daddr))
1144 hlimit = np->mcast_hops; 1140 hlimit = np->mcast_hops;
1145 else 1141 else
1146 hlimit = np->hop_limit; 1142 hlimit = np->hop_limit;
@@ -1175,7 +1171,7 @@ do_append_data:
1175 up->len += ulen; 1171 up->len += ulen;
1176 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag; 1172 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
1177 err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen, 1173 err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
1178 sizeof(struct udphdr), hlimit, tclass, opt, &fl, 1174 sizeof(struct udphdr), hlimit, tclass, opt, &fl6,
1179 (struct rt6_info*)dst, 1175 (struct rt6_info*)dst,
1180 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags, dontfrag); 1176 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags, dontfrag);
1181 if (err) 1177 if (err)
@@ -1188,10 +1184,10 @@ do_append_data:
1188 if (dst) { 1184 if (dst) {
1189 if (connected) { 1185 if (connected) {
1190 ip6_dst_store(sk, dst, 1186 ip6_dst_store(sk, dst,
1191 ipv6_addr_equal(&fl.fl6_dst, &np->daddr) ? 1187 ipv6_addr_equal(&fl6.daddr, &np->daddr) ?
1192 &np->daddr : NULL, 1188 &np->daddr : NULL,
1193#ifdef CONFIG_IPV6_SUBTREES 1189#ifdef CONFIG_IPV6_SUBTREES
1194 ipv6_addr_equal(&fl.fl6_src, &np->saddr) ? 1190 ipv6_addr_equal(&fl6.saddr, &np->saddr) ?
1195 &np->saddr : 1191 &np->saddr :
1196#endif 1192#endif
1197 NULL); 1193 NULL);
@@ -1299,7 +1295,7 @@ static int udp6_ufo_send_check(struct sk_buff *skb)
1299 return 0; 1295 return 0;
1300} 1296}
1301 1297
1302static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, int features) 1298static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, u32 features)
1303{ 1299{
1304 struct sk_buff *segs = ERR_PTR(-EINVAL); 1300 struct sk_buff *segs = ERR_PTR(-EINVAL);
1305 unsigned int mss; 1301 unsigned int mss;
@@ -1339,7 +1335,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, int features)
1339 skb->ip_summed = CHECKSUM_NONE; 1335 skb->ip_summed = CHECKSUM_NONE;
1340 1336
1341 /* Check if there is enough headroom to insert fragment header. */ 1337 /* Check if there is enough headroom to insert fragment header. */
1342 if ((skb_headroom(skb) < frag_hdr_sz) && 1338 if ((skb_mac_header(skb) < skb->head + frag_hdr_sz) &&
1343 pskb_expand_head(skb, frag_hdr_sz, 0, GFP_ATOMIC)) 1339 pskb_expand_head(skb, frag_hdr_sz, 0, GFP_ATOMIC))
1344 goto out; 1340 goto out;
1345 1341
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index da87428681cc..05e34c8ec913 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -27,18 +27,19 @@
27static struct xfrm_policy_afinfo xfrm6_policy_afinfo; 27static struct xfrm_policy_afinfo xfrm6_policy_afinfo;
28 28
29static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, 29static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos,
30 xfrm_address_t *saddr, 30 const xfrm_address_t *saddr,
31 xfrm_address_t *daddr) 31 const xfrm_address_t *daddr)
32{ 32{
33 struct flowi fl = {}; 33 struct flowi6 fl6;
34 struct dst_entry *dst; 34 struct dst_entry *dst;
35 int err; 35 int err;
36 36
37 memcpy(&fl.fl6_dst, daddr, sizeof(fl.fl6_dst)); 37 memset(&fl6, 0, sizeof(fl6));
38 memcpy(&fl6.daddr, daddr, sizeof(fl6.daddr));
38 if (saddr) 39 if (saddr)
39 memcpy(&fl.fl6_src, saddr, sizeof(fl.fl6_src)); 40 memcpy(&fl6.saddr, saddr, sizeof(fl6.saddr));
40 41
41 dst = ip6_route_output(net, NULL, &fl); 42 dst = ip6_route_output(net, NULL, &fl6);
42 43
43 err = dst->error; 44 err = dst->error;
44 if (dst->error) { 45 if (dst->error) {
@@ -67,7 +68,7 @@ static int xfrm6_get_saddr(struct net *net,
67 return 0; 68 return 0;
68} 69}
69 70
70static int xfrm6_get_tos(struct flowi *fl) 71static int xfrm6_get_tos(const struct flowi *fl)
71{ 72{
72 return 0; 73 return 0;
73} 74}
@@ -87,7 +88,7 @@ static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst,
87} 88}
88 89
89static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, 90static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
90 struct flowi *fl) 91 const struct flowi *fl)
91{ 92{
92 struct rt6_info *rt = (struct rt6_info*)xdst->route; 93 struct rt6_info *rt = (struct rt6_info*)xdst->route;
93 94
@@ -120,6 +121,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
120static inline void 121static inline void
121_decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) 122_decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
122{ 123{
124 struct flowi6 *fl6 = &fl->u.ip6;
123 int onlyproto = 0; 125 int onlyproto = 0;
124 u16 offset = skb_network_header_len(skb); 126 u16 offset = skb_network_header_len(skb);
125 struct ipv6hdr *hdr = ipv6_hdr(skb); 127 struct ipv6hdr *hdr = ipv6_hdr(skb);
@@ -127,11 +129,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
127 const unsigned char *nh = skb_network_header(skb); 129 const unsigned char *nh = skb_network_header(skb);
128 u8 nexthdr = nh[IP6CB(skb)->nhoff]; 130 u8 nexthdr = nh[IP6CB(skb)->nhoff];
129 131
130 memset(fl, 0, sizeof(struct flowi)); 132 memset(fl6, 0, sizeof(struct flowi6));
131 fl->mark = skb->mark; 133 fl6->flowi6_mark = skb->mark;
132 134
133 ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr); 135 ipv6_addr_copy(&fl6->daddr, reverse ? &hdr->saddr : &hdr->daddr);
134 ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr); 136 ipv6_addr_copy(&fl6->saddr, reverse ? &hdr->daddr : &hdr->saddr);
135 137
136 while (nh + offset + 1 < skb->data || 138 while (nh + offset + 1 < skb->data ||
137 pskb_may_pull(skb, nh + offset + 1 - skb->data)) { 139 pskb_may_pull(skb, nh + offset + 1 - skb->data)) {
@@ -158,20 +160,20 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
158 pskb_may_pull(skb, nh + offset + 4 - skb->data))) { 160 pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
159 __be16 *ports = (__be16 *)exthdr; 161 __be16 *ports = (__be16 *)exthdr;
160 162
161 fl->fl_ip_sport = ports[!!reverse]; 163 fl6->fl6_sport = ports[!!reverse];
162 fl->fl_ip_dport = ports[!reverse]; 164 fl6->fl6_dport = ports[!reverse];
163 } 165 }
164 fl->proto = nexthdr; 166 fl6->flowi6_proto = nexthdr;
165 return; 167 return;
166 168
167 case IPPROTO_ICMPV6: 169 case IPPROTO_ICMPV6:
168 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) { 170 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
169 u8 *icmp = (u8 *)exthdr; 171 u8 *icmp = (u8 *)exthdr;
170 172
171 fl->fl_icmp_type = icmp[0]; 173 fl6->fl6_icmp_type = icmp[0];
172 fl->fl_icmp_code = icmp[1]; 174 fl6->fl6_icmp_code = icmp[1];
173 } 175 }
174 fl->proto = nexthdr; 176 fl6->flowi6_proto = nexthdr;
175 return; 177 return;
176 178
177#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 179#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
@@ -180,9 +182,9 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
180 struct ip6_mh *mh; 182 struct ip6_mh *mh;
181 mh = (struct ip6_mh *)exthdr; 183 mh = (struct ip6_mh *)exthdr;
182 184
183 fl->fl_mh_type = mh->ip6mh_type; 185 fl6->fl6_mh_type = mh->ip6mh_type;
184 } 186 }
185 fl->proto = nexthdr; 187 fl6->flowi6_proto = nexthdr;
186 return; 188 return;
187#endif 189#endif
188 190
@@ -191,8 +193,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
191 case IPPROTO_ESP: 193 case IPPROTO_ESP:
192 case IPPROTO_COMP: 194 case IPPROTO_COMP:
193 default: 195 default:
194 fl->fl_ipsec_spi = 0; 196 fl6->fl6_ipsec_spi = 0;
195 fl->proto = nexthdr; 197 fl6->flowi6_proto = nexthdr;
196 return; 198 return;
197 } 199 }
198 } 200 }
@@ -220,6 +222,7 @@ static void xfrm6_dst_destroy(struct dst_entry *dst)
220 222
221 if (likely(xdst->u.rt6.rt6i_idev)) 223 if (likely(xdst->u.rt6.rt6i_idev))
222 in6_dev_put(xdst->u.rt6.rt6i_idev); 224 in6_dev_put(xdst->u.rt6.rt6i_idev);
225 dst_destroy_metrics_generic(dst);
223 if (likely(xdst->u.rt6.rt6i_peer)) 226 if (likely(xdst->u.rt6.rt6i_peer))
224 inet_putpeer(xdst->u.rt6.rt6i_peer); 227 inet_putpeer(xdst->u.rt6.rt6i_peer);
225 xfrm_dst_destroy(xdst); 228 xfrm_dst_destroy(xdst);
@@ -257,6 +260,7 @@ static struct dst_ops xfrm6_dst_ops = {
257 .protocol = cpu_to_be16(ETH_P_IPV6), 260 .protocol = cpu_to_be16(ETH_P_IPV6),
258 .gc = xfrm6_garbage_collect, 261 .gc = xfrm6_garbage_collect,
259 .update_pmtu = xfrm6_update_pmtu, 262 .update_pmtu = xfrm6_update_pmtu,
263 .cow_metrics = dst_cow_metrics_generic,
260 .destroy = xfrm6_dst_destroy, 264 .destroy = xfrm6_dst_destroy,
261 .ifdown = xfrm6_dst_ifdown, 265 .ifdown = xfrm6_dst_ifdown,
262 .local_out = __ip6_local_out, 266 .local_out = __ip6_local_out,
@@ -272,6 +276,7 @@ static struct xfrm_policy_afinfo xfrm6_policy_afinfo = {
272 .get_tos = xfrm6_get_tos, 276 .get_tos = xfrm6_get_tos,
273 .init_path = xfrm6_init_path, 277 .init_path = xfrm6_init_path,
274 .fill_dst = xfrm6_fill_dst, 278 .fill_dst = xfrm6_fill_dst,
279 .blackhole_route = ip6_blackhole_route,
275}; 280};
276 281
277static int __init xfrm6_policy_init(void) 282static int __init xfrm6_policy_init(void)
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
index a67575d472a3..afe941e9415c 100644
--- a/net/ipv6/xfrm6_state.c
+++ b/net/ipv6/xfrm6_state.c
@@ -20,26 +20,28 @@
20#include <net/addrconf.h> 20#include <net/addrconf.h>
21 21
22static void 22static void
23__xfrm6_init_tempsel(struct xfrm_selector *sel, struct flowi *fl) 23__xfrm6_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl)
24{ 24{
25 const struct flowi6 *fl6 = &fl->u.ip6;
26
25 /* Initialize temporary selector matching only 27 /* Initialize temporary selector matching only
26 * to current session. */ 28 * to current session. */
27 ipv6_addr_copy((struct in6_addr *)&sel->daddr, &fl->fl6_dst); 29 ipv6_addr_copy((struct in6_addr *)&sel->daddr, &fl6->daddr);
28 ipv6_addr_copy((struct in6_addr *)&sel->saddr, &fl->fl6_src); 30 ipv6_addr_copy((struct in6_addr *)&sel->saddr, &fl6->saddr);
29 sel->dport = xfrm_flowi_dport(fl); 31 sel->dport = xfrm_flowi_dport(fl, &fl6->uli);
30 sel->dport_mask = htons(0xffff); 32 sel->dport_mask = htons(0xffff);
31 sel->sport = xfrm_flowi_sport(fl); 33 sel->sport = xfrm_flowi_sport(fl, &fl6->uli);
32 sel->sport_mask = htons(0xffff); 34 sel->sport_mask = htons(0xffff);
33 sel->family = AF_INET6; 35 sel->family = AF_INET6;
34 sel->prefixlen_d = 128; 36 sel->prefixlen_d = 128;
35 sel->prefixlen_s = 128; 37 sel->prefixlen_s = 128;
36 sel->proto = fl->proto; 38 sel->proto = fl6->flowi6_proto;
37 sel->ifindex = fl->oif; 39 sel->ifindex = fl6->flowi6_oif;
38} 40}
39 41
40static void 42static void
41xfrm6_init_temprop(struct xfrm_state *x, struct xfrm_tmpl *tmpl, 43xfrm6_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl,
42 xfrm_address_t *daddr, xfrm_address_t *saddr) 44 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
43{ 45{
44 x->id = tmpl->id; 46 x->id = tmpl->id;
45 if (ipv6_addr_any((struct in6_addr*)&x->id.daddr)) 47 if (ipv6_addr_any((struct in6_addr*)&x->id.daddr))