diff options
Diffstat (limited to 'net/ipv6')
| -rw-r--r-- | net/ipv6/addrconf.c | 40 | ||||
| -rw-r--r-- | net/ipv6/af_inet6.c | 1 | ||||
| -rw-r--r-- | net/ipv6/ah6.c | 2 | ||||
| -rw-r--r-- | net/ipv6/datagram.c | 1 | ||||
| -rw-r--r-- | net/ipv6/esp6.c | 2 | ||||
| -rw-r--r-- | net/ipv6/icmp.c | 8 | ||||
| -rw-r--r-- | net/ipv6/inet6_connection_sock.c | 4 | ||||
| -rw-r--r-- | net/ipv6/ipcomp6.c | 2 | ||||
| -rw-r--r-- | net/ipv6/ping.c | 2 | ||||
| -rw-r--r-- | net/ipv6/raw.c | 1 | ||||
| -rw-r--r-- | net/ipv6/route.c | 86 | ||||
| -rw-r--r-- | net/ipv6/syncookies.c | 5 | ||||
| -rw-r--r-- | net/ipv6/sysctl_net_ipv6.c | 7 | ||||
| -rw-r--r-- | net/ipv6/tcp_ipv6.c | 3 | ||||
| -rw-r--r-- | net/ipv6/udp.c | 1 | 
15 files changed, 111 insertions, 54 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 4ab4c38958c..cec8cb4d292 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -198,6 +198,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {  	.accept_ra_rt_info_max_plen = 0,  #endif  #endif +	.accept_ra_rt_table	= 0,  	.proxy_ndp		= 0,  	.accept_source_route	= 0,	/* we do not accept RH0 by default. */  	.disable_ipv6		= 0, @@ -232,6 +233,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {  	.accept_ra_rt_info_max_plen = 0,  #endif  #endif +	.accept_ra_rt_table	= 0,  	.proxy_ndp		= 0,  	.accept_source_route	= 0,	/* we do not accept RH0 by default. */  	.disable_ipv6		= 0, @@ -1910,6 +1912,31 @@ static void  __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmp  }  #endif +u32 addrconf_rt_table(const struct net_device *dev, u32 default_table) { +	/* Determines into what table to put autoconf PIO/RIO/default routes +	 * learned on this device. +	 * +	 * - If 0, use the same table for every device. This puts routes into +	 *   one of RT_TABLE_{PREFIX,INFO,DFLT} depending on the type of route +	 *   (but note that these three are currently all equal to +	 *   RT6_TABLE_MAIN). +	 * - If > 0, use the specified table. +	 * - If < 0, put routes into table dev->ifindex + (-rt_table). +	 */ +	struct inet6_dev *idev = in6_dev_get(dev); +	u32 table; +	int sysctl = idev->cnf.accept_ra_rt_table; +	if (sysctl == 0) { +		table = default_table; +	} else if (sysctl > 0) { +		table = (u32) sysctl; +	} else { +		table = (unsigned) dev->ifindex + (-sysctl); +	} +	in6_dev_put(idev); +	return table; +} +  /*   *	Add prefix route.   */ @@ -1919,7 +1946,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,  		      unsigned long expires, u32 flags)  {  	struct fib6_config cfg = { -		.fc_table = RT6_TABLE_PREFIX, +		.fc_table = addrconf_rt_table(dev, RT6_TABLE_PREFIX),  		.fc_metric = IP6_RT_PRIO_ADDRCONF,  		.fc_ifindex = dev->ifindex,  		.fc_expires = expires, @@ -1953,7 +1980,8 @@ static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,  	struct rt6_info *rt = NULL;  	struct fib6_table *table; -	table = fib6_get_table(dev_net(dev), RT6_TABLE_PREFIX); +	table = fib6_get_table(dev_net(dev), +			       addrconf_rt_table(dev, RT6_TABLE_PREFIX));  	if (table == NULL)  		return NULL; @@ -4159,6 +4187,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,  	array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen;  #endif  #endif +	array[DEVCONF_ACCEPT_RA_RT_TABLE] = cnf->accept_ra_rt_table;  	array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp;  	array[DEVCONF_ACCEPT_SOURCE_ROUTE] = cnf->accept_source_route;  #ifdef CONFIG_IPV6_OPTIMISTIC_DAD @@ -4868,6 +4897,13 @@ static struct addrconf_sysctl_table  #endif  #endif  		{ +			.procname	= "accept_ra_rt_table", +			.data		= &ipv6_devconf.accept_ra_rt_table, +			.maxlen		= sizeof(int), +			.mode		= 0644, +			.proc_handler	= proc_dointvec, +		}, +		{  			.procname	= "proxy_ndp",  			.data		= &ipv6_devconf.proxy_ndp,  			.maxlen		= sizeof(int), diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index f0081f9cc84..ae17f62189a 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -695,6 +695,7 @@ int inet6_sk_rebuild_header(struct sock *sk)  		fl6.flowi6_mark = sk->sk_mark;  		fl6.fl6_dport = inet->inet_dport;  		fl6.fl6_sport = inet->inet_sport; +		fl6.flowi6_uid = sock_i_uid(sk);  		security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));  		final_p = fl6_update_dst(&fl6, np->opt, &final); diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index bb02e176cb7..b903e19463c 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -630,7 +630,7 @@ static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,  	if (type == NDISC_REDIRECT)  		ip6_redirect(skb, net, 0, 0);  	else -		ip6_update_pmtu(skb, net, info, 0, 0); +		ip6_update_pmtu(skb, net, info, 0, 0, INVALID_UID);  	xfrm_state_put(x);  } diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 4b56cbbc789..00b4a5f6eea 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -162,6 +162,7 @@ ipv4_connected:  	fl6.flowi6_mark = sk->sk_mark;  	fl6.fl6_dport = inet->inet_dport;  	fl6.fl6_sport = inet->inet_sport; +	fl6.flowi6_uid = sock_i_uid(sk);  	if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST))  		fl6.flowi6_oif = np->mcast_oif; diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 40ffd72243a..fdc81cb29e8 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -449,7 +449,7 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,  	if (type == NDISC_REDIRECT)  		ip6_redirect(skb, net, 0, 0);  	else -		ip6_update_pmtu(skb, net, info, 0, 0); +		ip6_update_pmtu(skb, net, info, 0, 0, INVALID_UID);  	xfrm_state_put(x);  } diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 1d2902e6178..12b1a942dc9 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -90,7 +90,7 @@ static void icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,  	struct net *net = dev_net(skb->dev);  	if (type == ICMPV6_PKT_TOOBIG) -		ip6_update_pmtu(skb, net, info, 0, 0); +		ip6_update_pmtu(skb, net, info, 0, 0, INVALID_UID);  	else if (type == NDISC_REDIRECT)  		ip6_redirect(skb, net, 0, 0); @@ -397,6 +397,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)  	int len;  	int hlimit;  	int err = 0; +	u32 mark = IP6_REPLY_MARK(net, skb->mark);  	if ((u8 *)hdr < skb->head ||  	    (skb->network_header + sizeof(*hdr)) > skb->tail) @@ -462,6 +463,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)  	fl6.daddr = hdr->saddr;  	if (saddr)  		fl6.saddr = *saddr; +	fl6.flowi6_mark = mark;  	fl6.flowi6_oif = iif;  	fl6.fl6_icmp_type = type;  	fl6.fl6_icmp_code = code; @@ -470,6 +472,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)  	sk = icmpv6_xmit_lock(net);  	if (sk == NULL)  		return; +	sk->sk_mark = mark;  	np = inet6_sk(sk);  	if (!icmpv6_xrlim_allow(sk, type, &fl6)) @@ -551,6 +554,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)  	struct dst_entry *dst;  	int err = 0;  	int hlimit; +	u32 mark = IP6_REPLY_MARK(net, skb->mark);  	saddr = &ipv6_hdr(skb)->daddr; @@ -567,11 +571,13 @@ static void icmpv6_echo_reply(struct sk_buff *skb)  		fl6.saddr = *saddr;  	fl6.flowi6_oif = skb->dev->ifindex;  	fl6.fl6_icmp_type = ICMPV6_ECHO_REPLY; +	fl6.flowi6_mark = mark;  	security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));  	sk = icmpv6_xmit_lock(net);  	if (sk == NULL)  		return; +	sk->sk_mark = mark;  	np = inet6_sk(sk);  	if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c index e4311cbc8b4..65a46058c85 100644 --- a/net/ipv6/inet6_connection_sock.c +++ b/net/ipv6/inet6_connection_sock.c @@ -81,9 +81,10 @@ struct dst_entry *inet6_csk_route_req(struct sock *sk,  	final_p = fl6_update_dst(fl6, np->opt, &final);  	fl6->saddr = treq->loc_addr;  	fl6->flowi6_oif = treq->iif; -	fl6->flowi6_mark = sk->sk_mark; +	fl6->flowi6_mark = inet_rsk(req)->ir_mark;  	fl6->fl6_dport = inet_rsk(req)->rmt_port;  	fl6->fl6_sport = inet_rsk(req)->loc_port; +	fl6->flowi6_uid = sock_i_uid(sk);  	security_req_classify_flow(req, flowi6_to_flowi(fl6));  	dst = ip6_dst_lookup_flow(sk, fl6, final_p, false); @@ -211,6 +212,7 @@ static struct dst_entry *inet6_csk_route_socket(struct sock *sk,  	fl6->flowi6_mark = sk->sk_mark;  	fl6->fl6_sport = inet->inet_sport;  	fl6->fl6_dport = inet->inet_dport; +	fl6->flowi6_uid = sock_i_uid(sk);  	security_sk_classify_flow(sk, flowi6_to_flowi(fl6));  	final_p = fl6_update_dst(fl6, np->opt, &final); diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 7af5aee75d9..a1beb59a841 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c @@ -78,7 +78,7 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,  	if (type == NDISC_REDIRECT)  		ip6_redirect(skb, net, 0, 0);  	else -		ip6_update_pmtu(skb, net, info, 0, 0); +		ip6_update_pmtu(skb, net, info, 0, 0, INVALID_UID);  	xfrm_state_put(x);  } diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index e2cc17cd1cf..5f0d294b36c 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c @@ -158,6 +158,8 @@ int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,  	fl6.flowi6_proto = IPPROTO_ICMPV6;  	fl6.saddr = np->saddr;  	fl6.daddr = *daddr; +	fl6.flowi6_mark = sk->sk_mark; +	fl6.flowi6_uid = sock_i_uid(sk);  	fl6.fl6_icmp_type = user_icmph.icmp6_type;  	fl6.fl6_icmp_code = user_icmph.icmp6_code;  	security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index eedff8ccded..dfef31581f8 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -761,6 +761,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,  	memset(&fl6, 0, sizeof(fl6));  	fl6.flowi6_mark = sk->sk_mark; +	fl6.flowi6_uid = sock_i_uid(sk);  	if (sin6) {  		if (addr_len < SIN6_LEN_RFC2133) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index ad0aa6b0b86..bad36468dcd 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -85,13 +85,12 @@ static void		rt6_do_redirect(struct dst_entry *dst, struct sock *sk,  					struct sk_buff *skb);  #ifdef CONFIG_IPV6_ROUTE_INFO -static struct rt6_info *rt6_add_route_info(struct net *net, +static struct rt6_info *rt6_add_route_info(struct net_device *dev,  					   const struct in6_addr *prefix, int prefixlen, -					   const struct in6_addr *gwaddr, int ifindex, -					   unsigned int pref); -static struct rt6_info *rt6_get_route_info(struct net *net, +					   const struct in6_addr *gwaddr, unsigned int pref); +static struct rt6_info *rt6_get_route_info(struct net_device *dev,  					   const struct in6_addr *prefix, int prefixlen, -					   const struct in6_addr *gwaddr, int ifindex); +					   const struct in6_addr *gwaddr);  #endif  static u32 *ipv6_cow_metrics(struct dst_entry *dst, unsigned long old) @@ -643,7 +642,6 @@ static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict)  int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,  		  const struct in6_addr *gwaddr)  { -	struct net *net = dev_net(dev);  	struct route_info *rinfo = (struct route_info *) opt;  	struct in6_addr prefix_buf, *prefix;  	unsigned int pref; @@ -685,8 +683,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,  		prefix = &prefix_buf;  	} -	rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, gwaddr, -				dev->ifindex); +	rt = rt6_get_route_info(dev, prefix, rinfo->prefix_len, gwaddr);  	if (rt && !lifetime) {  		ip6_del_rt(rt); @@ -694,8 +691,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,  	}  	if (!rt && lifetime) -		rt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr, dev->ifindex, -					pref); +		rt = rt6_add_route_info(dev, prefix, rinfo->prefix_len, gwaddr, pref);  	else if (rt)  		rt->rt6i_flags = RTF_ROUTEINFO |  				 (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); @@ -1103,7 +1099,7 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,  }  void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, -		     int oif, u32 mark) +		     int oif, u32 mark, kuid_t uid)  {  	const struct ipv6hdr *iph = (struct ipv6hdr *) skb->data;  	struct dst_entry *dst; @@ -1111,11 +1107,12 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,  	memset(&fl6, 0, sizeof(fl6));  	fl6.flowi6_oif = oif; -	fl6.flowi6_mark = mark; +	fl6.flowi6_mark = mark ? mark : IP6_REPLY_MARK(net, skb->mark);  	fl6.flowi6_flags = 0;  	fl6.daddr = iph->daddr;  	fl6.saddr = iph->saddr;  	fl6.flowlabel = ip6_flowinfo(iph); +	fl6.flowi6_uid = uid;  	dst = ip6_route_output(net, NULL, &fl6);  	if (!dst->error) @@ -1127,7 +1124,7 @@ EXPORT_SYMBOL_GPL(ip6_update_pmtu);  void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu)  {  	ip6_update_pmtu(skb, sock_net(sk), mtu, -			sk->sk_bound_dev_if, sk->sk_mark); +			sk->sk_bound_dev_if, sk->sk_mark, sock_i_uid(sk));  }  EXPORT_SYMBOL_GPL(ip6_sk_update_pmtu); @@ -1796,15 +1793,16 @@ static struct rt6_info *ip6_rt_copy(struct rt6_info *ort,  }  #ifdef CONFIG_IPV6_ROUTE_INFO -static struct rt6_info *rt6_get_route_info(struct net *net, +static struct rt6_info *rt6_get_route_info(struct net_device *dev,  					   const struct in6_addr *prefix, int prefixlen, -					   const struct in6_addr *gwaddr, int ifindex) +					   const struct in6_addr *gwaddr)  {  	struct fib6_node *fn;  	struct rt6_info *rt = NULL;  	struct fib6_table *table; -	table = fib6_get_table(net, RT6_TABLE_INFO); +	table = fib6_get_table(dev_net(dev), +			       addrconf_rt_table(dev, RT6_TABLE_INFO));  	if (!table)  		return NULL; @@ -1814,7 +1812,7 @@ static struct rt6_info *rt6_get_route_info(struct net *net,  		goto out;  	for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) { -		if (rt->dst.dev->ifindex != ifindex) +		if (rt->dst.dev->ifindex != dev->ifindex)  			continue;  		if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY))  			continue; @@ -1828,21 +1826,20 @@ out:  	return rt;  } -static struct rt6_info *rt6_add_route_info(struct net *net, +static struct rt6_info *rt6_add_route_info(struct net_device *dev,  					   const struct in6_addr *prefix, int prefixlen, -					   const struct in6_addr *gwaddr, int ifindex, -					   unsigned int pref) +					   const struct in6_addr *gwaddr, unsigned int pref)  {  	struct fib6_config cfg = { -		.fc_table	= RT6_TABLE_INFO, +		.fc_table	= addrconf_rt_table(dev, RT6_TABLE_INFO),  		.fc_metric	= IP6_RT_PRIO_USER, -		.fc_ifindex	= ifindex, +		.fc_ifindex	= dev->ifindex,  		.fc_dst_len	= prefixlen,  		.fc_flags	= RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO |  				  RTF_UP | RTF_PREF(pref),  		.fc_nlinfo.portid = 0,  		.fc_nlinfo.nlh = NULL, -		.fc_nlinfo.nl_net = net, +		.fc_nlinfo.nl_net = dev_net(dev),  	};  	cfg.fc_dst = *prefix; @@ -1854,7 +1851,7 @@ static struct rt6_info *rt6_add_route_info(struct net *net,  	ip6_route_add(&cfg); -	return rt6_get_route_info(net, prefix, prefixlen, gwaddr, ifindex); +	return rt6_get_route_info(dev, prefix, prefixlen, gwaddr);  }  #endif @@ -1863,7 +1860,8 @@ struct rt6_info *rt6_get_dflt_router(const struct in6_addr *addr, struct net_dev  	struct rt6_info *rt;  	struct fib6_table *table; -	table = fib6_get_table(dev_net(dev), RT6_TABLE_DFLT); +	table = fib6_get_table(dev_net(dev), +			       addrconf_rt_table(dev, RT6_TABLE_MAIN));  	if (!table)  		return NULL; @@ -1885,7 +1883,7 @@ struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr,  				     unsigned int pref)  {  	struct fib6_config cfg = { -		.fc_table	= RT6_TABLE_DFLT, +		.fc_table	= addrconf_rt_table(dev, RT6_TABLE_DFLT),  		.fc_metric	= IP6_RT_PRIO_USER,  		.fc_ifindex	= dev->ifindex,  		.fc_flags	= RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT | @@ -1902,28 +1900,17 @@ struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr,  	return rt6_get_dflt_router(gwaddr, dev);  } -void rt6_purge_dflt_routers(struct net *net) -{ -	struct rt6_info *rt; -	struct fib6_table *table; -	/* NOTE: Keep consistent with rt6_get_dflt_router */ -	table = fib6_get_table(net, RT6_TABLE_DFLT); -	if (!table) -		return; +int rt6_addrconf_purge(struct rt6_info *rt, void *arg) { +	if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF) && +	    (!rt->rt6i_idev || rt->rt6i_idev->cnf.accept_ra != 2)) +		return -1; +	return 0; +} -restart: -	read_lock_bh(&table->tb6_lock); -	for (rt = table->tb6_root.leaf; rt; rt = rt->dst.rt6_next) { -		if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF) && -		    (!rt->rt6i_idev || rt->rt6i_idev->cnf.accept_ra != 2)) { -			dst_hold(&rt->dst); -			read_unlock_bh(&table->tb6_lock); -			ip6_del_rt(rt); -			goto restart; -		} -	} -	read_unlock_bh(&table->tb6_lock); +void rt6_purge_dflt_routers(struct net *net) +{ +	fib6_clean_all(net, rt6_addrconf_purge, 0, NULL);  }  static void rtmsg_to_fib6_config(struct net *net, @@ -2213,6 +2200,7 @@ static const struct nla_policy rtm_ipv6_policy[RTA_MAX+1] = {  	[RTA_PRIORITY]          = { .type = NLA_U32 },  	[RTA_METRICS]           = { .type = NLA_NESTED },  	[RTA_MULTIPATH]		= { .len = sizeof(struct rtnexthop) }, +	[RTA_UID]		= { .type = NLA_U32 },  };  static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh, @@ -2599,6 +2587,12 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh)  	if (tb[RTA_OIF])  		oif = nla_get_u32(tb[RTA_OIF]); +	if (tb[RTA_UID]) +		fl6.flowi6_uid = make_kuid(current_user_ns(), +					   nla_get_u32(tb[RTA_UID])); +	else +		fl6.flowi6_uid = iif ? INVALID_UID : current_uid(); +  	if (iif) {  		struct net_device *dev;  		int flags = 0; diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index d5dda20bd71..ba8622daffd 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c @@ -212,6 +212,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)  	    ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL)  		ireq6->iif = inet6_iif(skb); +	ireq->ir_mark = inet_request_mark(sk, skb); +  	req->expires = 0UL;  	req->num_retrans = 0;  	ireq->ecn_ok		= ecn_ok; @@ -238,9 +240,10 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)  		final_p = fl6_update_dst(&fl6, np->opt, &final);  		fl6.saddr = ireq6->loc_addr;  		fl6.flowi6_oif = sk->sk_bound_dev_if; -		fl6.flowi6_mark = sk->sk_mark; +		fl6.flowi6_mark = ireq->ir_mark;  		fl6.fl6_dport = inet_rsk(req)->rmt_port;  		fl6.fl6_sport = inet_sk(sk)->inet_sport; +		fl6.flowi6_uid = sock_i_uid(sk);  		security_req_classify_flow(req, flowi6_to_flowi(&fl6));  		dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false); diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index e85c48bd404..53a9f5a6453 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c @@ -24,6 +24,13 @@ static ctl_table ipv6_table_template[] = {  		.mode		= 0644,  		.proc_handler	= proc_dointvec  	}, +	{ +		.procname	= "fwmark_reflect", +		.data		= &init_net.ipv6.sysctl.fwmark_reflect, +		.maxlen		= sizeof(int), +		.mode		= 0644, +		.proc_handler	= proc_dointvec +	},  	{ }  }; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 0a17ed9eaf3..a4fc647deb0 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -252,6 +252,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,  	fl6.flowi6_mark = sk->sk_mark;  	fl6.fl6_dport = usin->sin6_port;  	fl6.fl6_sport = inet->inet_sport; +	fl6.flowi6_uid = sock_i_uid(sk);  	final_p = fl6_update_dst(&fl6, np->opt, &final); @@ -791,6 +792,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,  	fl6.flowi6_proto = IPPROTO_TCP;  	if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)  		fl6.flowi6_oif = inet6_iif(skb); +	fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark);  	fl6.fl6_dport = t1->dest;  	fl6.fl6_sport = t1->source;  	security_skb_classify_flow(skb, flowi6_to_flowi(&fl6)); @@ -999,6 +1001,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)  		TCP_ECN_create_request(req, skb, sock_net(sk));  	treq->iif = sk->sk_bound_dev_if; +	inet_rsk(req)->ir_mark = inet_request_mark(sk, skb);  	/* So that link locals have meaning */  	if (!sk->sk_bound_dev_if && diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 42923b14dfa..e6dd85da906 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1147,6 +1147,7 @@ do_udp_sendmsg:  		fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex;  	fl6.flowi6_mark = sk->sk_mark; +	fl6.flowi6_uid = sock_i_uid(sk);  	if (msg->msg_controllen) {  		opt = &opt_space;  |