Subject: linux-next: manual merge of the net-next tree with the bpf tree

From: Stephen Rothwell <[email-masked]>
Date: Mon, 3 Dec 2018 13:16:29 +1100

Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  net/core/filter.c

between commits:

  b7df9ada9a77 ("bpf: fix pointer offsets in context for 32 bit")
  f71c6143c203 ("bpf: Support sk lookup in netns with id 0")

from the bpf tree and commits:

  c8123ead13a5 ("bpf: Extend the sk_lookup() helper to XDP hookpoint.")
  f11216b24219 ("bpf: add skb->tstamp r/w access from tc clsact and cg skb progs")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc net/core/filter.c
index 8d2c629501e2,bd0df75dc7b6..000000000000
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@@ -4887,26 -5067,26 +5067,27 @@@ __bpf_sk_lookup(struct sk_buff *skb, st
  	struct sock *sk = NULL;
  	u8 family = AF_UNSPEC;
  	struct net *net;
+ 	int sdif;
  
  	family = len == sizeof(tuple->ipv4) ? AF_INET : AF_INET6;
 -	if (unlikely(family == AF_UNSPEC || netns_id > U32_MAX || flags))
 +	if (unlikely(family == AF_UNSPEC || flags ||
 +		     !((s32)netns_id < 0 || netns_id <= S32_MAX)))
  		goto out;
  
- 	if (skb->dev)
- 		caller_net = dev_net(skb->dev);
+ 	if (family == AF_INET)
+ 		sdif = inet_sdif(skb);
  	else
- 		caller_net = sock_net(skb->sk);
+ 		sdif = inet6_sdif(skb);
+ 
 -	if (netns_id) {
 +	if ((s32)netns_id < 0) {
 +		net = caller_net;
- 		sk = sk_lookup(net, tuple, skb, family, proto);
++		sk = sk_lookup(net, tuple, ifindex, sdif, family, proto);
 +	} else {
  		net = get_net_ns_by_id(caller_net, netns_id);
  		if (unlikely(!net))
  			goto out;
- 		sk = sk_lookup(net, tuple, skb, family, proto);
+ 		sk = sk_lookup(net, tuple, ifindex, sdif, family, proto);
  		put_net(net);
 -	} else {
 -		net = caller_net;
 -		sk = sk_lookup(net, tuple, ifindex, sdif, family, proto);
  	}
  
  	if (sk)
@@@ -5436,10 -5737,14 +5738,14 @@@ static bool bpf_skb_is_valid_access(in
  		if (size != size_default)
  			return false;
  		break;
 -	case bpf_ctx_range(struct __sk_buff, flow_keys):
 -		if (size != sizeof(struct bpf_flow_keys *))
 +	case bpf_ctx_range_ptr(struct __sk_buff, flow_keys):
 +		if (size != sizeof(__u64))
  			return false;
  		break;
+ 	case bpf_ctx_range(struct __sk_buff, tstamp):
+ 		if (size != sizeof(__u64))
+ 			return false;
+ 		break;
  	default:
  		/* Only narrow read access allowed for now. */
  		if (type == BPF_WRITE) {
@@@ -5465,8 -5770,9 +5771,9 @@@ static bool sk_filter_is_valid_access(i
  	case bpf_ctx_range(struct __sk_buff, data):
  	case bpf_ctx_range(struct __sk_buff, data_meta):
  	case bpf_ctx_range(struct __sk_buff, data_end):
 -	case bpf_ctx_range(struct __sk_buff, flow_keys):
 +	case bpf_ctx_range_ptr(struct __sk_buff, flow_keys):
  	case bpf_ctx_range_till(struct __sk_buff, family, local_port):
+ 	case bpf_ctx_range(struct __sk_buff, tstamp):
  		return false;
  	}
  
@@@ -5531,7 -5841,8 +5842,8 @@@ static bool lwt_is_valid_access(int off
  	case bpf_ctx_range(struct __sk_buff, tc_classid):
  	case bpf_ctx_range_till(struct __sk_buff, family, local_port):
  	case bpf_ctx_range(struct __sk_buff, data_meta):
 -	case bpf_ctx_range(struct __sk_buff, flow_keys):
 +	case bpf_ctx_range_ptr(struct __sk_buff, flow_keys):
+ 	case bpf_ctx_range(struct __sk_buff, tstamp):
  		return false;
  	}
  
@@@ -5959,7 -6271,8 +6272,8 @@@ static bool sk_skb_is_valid_access(int 
  	switch (off) {
  	case bpf_ctx_range(struct __sk_buff, tc_classid):
  	case bpf_ctx_range(struct __sk_buff, data_meta):
 -	case bpf_ctx_range(struct __sk_buff, flow_keys):
 +	case bpf_ctx_range_ptr(struct __sk_buff, flow_keys):
+ 	case bpf_ctx_range(struct __sk_buff, tstamp):
  		return false;
  	}