From: David S. Miller Date: Sun, 26 Jul 2020 00:49:04 +0000 (-0700) Subject: Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net X-Git-Tag: v5.15~3197^2~126 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a57066b1a01977a646145f4ce8dfb4538b08368a;p=platform%2Fkernel%2Flinux-starfive.git Merge git://git./linux/kernel/git/netdev/net The UDP reuseport conflict was a little bit tricky. The net-next code, via bpf-next, extracted the reuseport handling into a helper so that the BPF sk lookup code could invoke it. At the same time, the logic for reuseport handling of unconnected sockets changed via commit efc6b6f6c3113e8b203b9debfb72d81e0f3dcace which changed the logic to carry on the reuseport result into the rest of the lookup loop if we do not return immediately. This requires moving the reuseport_has_conns() logic into the callers. While we are here, get rid of inline directives as they do not belong in foo.c files. The other changes were cases of more straightforward overlapping modifications. Signed-off-by: David S. Miller --- a57066b1a01977a646145f4ce8dfb4538b08368a diff --cc drivers/net/ethernet/aquantia/atlantic/aq_hw.h index 95ee133,992fedb..7df7401 --- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h @@@ -67,7 -64,7 +67,8 @@@ struct aq_hw_caps_s u8 rx_rings; bool flow_control; bool is_64_dma; + bool op64bit; + u32 quirks; u32 priv_data_len; }; diff --cc drivers/net/ethernet/freescale/enetc/enetc_pf.c index 1d2158f,7a9675b..26d5981b --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@@ -1052,7 -906,8 +1052,8 @@@ static int enetc_pf_probe(struct pci_de return 0; err_reg_netdev: + enetc_teardown_serdes(priv); + enetc_mdio_remove(pf); - enetc_of_put_phy(priv); enetc_free_msix(priv); err_alloc_msix: enetc_free_si_resources(priv); diff --cc drivers/net/geneve.c index 49b00de,dec52b7..017c13a --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@@ -1326,10 -1327,11 +1326,10 @@@ static void init_tnl_info(struct ip_tun static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack, - struct ip_tunnel_info *info, bool *metadata, - bool *use_udp6_rx_checksums, bool *ttl_inherit, - enum ifla_geneve_df *df, bool changelink) + struct geneve_config *cfg, bool changelink) { - int attrtype; + struct ip_tunnel_info *info = &cfg->info; + int attrtype; if (data[IFLA_GENEVE_REMOTE] && data[IFLA_GENEVE_REMOTE6]) { NL_SET_ERR_MSG(extack, diff --cc drivers/net/netdevsim/netdev.c index 9d0d180,23950e7..97cfb01 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@@ -323,10 -316,8 +323,10 @@@ nsim_create(struct nsim_dev *nsim_dev, err_ipsec_teardown: nsim_ipsec_teardown(ns); nsim_bpf_uninit(ns); - rtnl_unlock(); -err_rtnl_unlock: +err_utn_destroy: + rtnl_unlock(); + nsim_udp_tunnels_info_destroy(dev); +err_free_netdev: free_netdev(dev); return ERR_PTR(err); } diff --cc net/ipv4/udp.c index 5a6a2f6,4077d58..0fb5e4e --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@@ -409,25 -408,6 +409,22 @@@ static u32 udp_ehashfn(const struct ne udp_ehash_secret + net_hash_mix(net)); } - static inline struct sock *lookup_reuseport(struct net *net, struct sock *sk, - struct sk_buff *skb, - __be32 saddr, __be16 sport, - __be32 daddr, unsigned short hnum) ++static struct sock *lookup_reuseport(struct net *net, struct sock *sk, ++ struct sk_buff *skb, ++ __be32 saddr, __be16 sport, ++ __be32 daddr, unsigned short hnum) +{ + struct sock *reuse_sk = NULL; + u32 hash; + + if (sk->sk_reuseport && sk->sk_state != TCP_ESTABLISHED) { + hash = udp_ehashfn(net, daddr, hnum, saddr, sport); + reuse_sk = reuseport_select_sock(sk, hash, skb, + sizeof(struct udphdr)); - /* Fall back to scoring if group has connections */ - if (reuseport_has_conns(sk, false)) - return NULL; + } + return reuse_sk; +} + /* called with rcu_read_lock() */ static struct sock *udp4_lib_lookup2(struct net *net, __be32 saddr, __be16 sport, @@@ -445,41 -426,25 +442,42 @@@ score = compute_score(sk, net, saddr, sport, daddr, hnum, dif, sdif); if (score > badness) { - reuseport_result = NULL; - - if (sk->sk_reuseport && - sk->sk_state != TCP_ESTABLISHED) { - hash = udp_ehashfn(net, daddr, hnum, - saddr, sport); - reuseport_result = reuseport_select_sock(sk, hash, skb, - sizeof(struct udphdr)); - if (reuseport_result && !reuseport_has_conns(sk, false)) - return reuseport_result; - } + result = lookup_reuseport(net, sk, skb, + saddr, sport, daddr, hnum); - if (result) ++ /* Fall back to scoring if group has connections */ ++ if (result && !reuseport_has_conns(sk, false)) + return result; - result = reuseport_result ? : sk; ++ result = result ? : sk; badness = score; - result = sk; } } return result; } - static inline struct sock *udp4_lookup_run_bpf(struct net *net, - struct udp_table *udptable, - struct sk_buff *skb, - __be32 saddr, __be16 sport, - __be32 daddr, u16 hnum) ++static struct sock *udp4_lookup_run_bpf(struct net *net, ++ struct udp_table *udptable, ++ struct sk_buff *skb, ++ __be32 saddr, __be16 sport, ++ __be32 daddr, u16 hnum) +{ + struct sock *sk, *reuse_sk; + bool no_reuseport; + + if (udptable != &udp_table) + return NULL; /* only UDP is supported */ + + no_reuseport = bpf_sk_lookup_run_v4(net, IPPROTO_UDP, + saddr, sport, daddr, hnum, &sk); + if (no_reuseport || IS_ERR_OR_NULL(sk)) + return sk; + + reuse_sk = lookup_reuseport(net, sk, skb, saddr, sport, daddr, hnum); - if (reuse_sk) ++ if (reuse_sk && !reuseport_has_conns(sk, false)) + sk = reuse_sk; + return sk; +} + /* UDP is nearly always wildcards out the wazoo, it makes no sense to try * harder than this. -DaveM */ diff --cc net/ipv6/udp.c index 15818e1,a8d74f4..5530c9d --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@@ -141,27 -141,6 +141,27 @@@ static int compute_score(struct sock *s return score; } - static inline struct sock *lookup_reuseport(struct net *net, struct sock *sk, - struct sk_buff *skb, - const struct in6_addr *saddr, - __be16 sport, - const struct in6_addr *daddr, - unsigned int hnum) ++static struct sock *lookup_reuseport(struct net *net, struct sock *sk, ++ struct sk_buff *skb, ++ const struct in6_addr *saddr, ++ __be16 sport, ++ const struct in6_addr *daddr, ++ unsigned int hnum) +{ + struct sock *reuse_sk = NULL; + u32 hash; + + if (sk->sk_reuseport && sk->sk_state != TCP_ESTABLISHED) { + hash = udp6_ehashfn(net, daddr, hnum, saddr, sport); + reuse_sk = reuseport_select_sock(sk, hash, skb, + sizeof(struct udphdr)); + /* Fall back to scoring if group has connections */ + if (reuseport_has_conns(sk, false)) + return NULL; + } + return reuse_sk; +} + /* called with rcu_read_lock() */ static struct sock *udp6_lib_lookup2(struct net *net, const struct in6_addr *saddr, __be16 sport, @@@ -178,43 -158,26 +178,44 @@@ score = compute_score(sk, net, saddr, sport, daddr, hnum, dif, sdif); if (score > badness) { - reuseport_result = NULL; - - if (sk->sk_reuseport && - sk->sk_state != TCP_ESTABLISHED) { - hash = udp6_ehashfn(net, daddr, hnum, - saddr, sport); + result = lookup_reuseport(net, sk, skb, + saddr, sport, daddr, hnum); - if (result) ++ /* Fall back to scoring if group has connections */ ++ if (result && !reuseport_has_conns(sk, false)) + return result; - result = sk; - reuseport_result = reuseport_select_sock(sk, hash, skb, - sizeof(struct udphdr)); - if (reuseport_result && !reuseport_has_conns(sk, false)) - return reuseport_result; - } - - result = reuseport_result ? : sk; ++ result = result ? : sk; badness = score; } } return result; } +static inline struct sock *udp6_lookup_run_bpf(struct net *net, + struct udp_table *udptable, + struct sk_buff *skb, + const struct in6_addr *saddr, + __be16 sport, + const struct in6_addr *daddr, + u16 hnum) +{ + struct sock *sk, *reuse_sk; + bool no_reuseport; + + if (udptable != &udp_table) + return NULL; /* only UDP is supported */ + + no_reuseport = bpf_sk_lookup_run_v6(net, IPPROTO_UDP, + saddr, sport, daddr, hnum, &sk); + if (no_reuseport || IS_ERR_OR_NULL(sk)) + return sk; + + reuse_sk = lookup_reuseport(net, sk, skb, saddr, sport, daddr, hnum); - if (reuse_sk) ++ if (reuse_sk && !reuseport_has_conns(sk, false)) + sk = reuse_sk; + return sk; +} + /* rcu_read_lock() must be held */ struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport,