Skip to content

Commit 108d291

Browse files
author
CKI KWF Bot
committed
Merge: tunnels: stable backport for 9.8 phase 2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7408 JIRA: https://issues.redhat.com/browse/RHEL-115639 Upstream Status: linux.git Upstream fixes for vxlan and geneve. Signed-off-by: Guillaume Nault <gnault@redhat.com> Approved-by: Hangbin Liu <haliu@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents b9abd3a + a49d6c2 commit 108d291

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

drivers/net/geneve.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,21 +1859,9 @@ static void geneve_destroy_tunnels(struct net *net, struct list_head *head)
18591859
{
18601860
struct geneve_net *gn = net_generic(net, geneve_net_id);
18611861
struct geneve_dev *geneve, *next;
1862-
struct net_device *dev, *aux;
18631862

1864-
/* gather any geneve devices that were moved into this ns */
1865-
for_each_netdev_safe(net, dev, aux)
1866-
if (dev->rtnl_link_ops == &geneve_link_ops)
1867-
unregister_netdevice_queue(dev, head);
1868-
1869-
/* now gather any other geneve devices that were created in this ns */
1870-
list_for_each_entry_safe(geneve, next, &gn->geneve_list, next) {
1871-
/* If geneve->dev is in the same netns, it was already added
1872-
* to the list by the previous loop.
1873-
*/
1874-
if (!net_eq(dev_net(geneve->dev), net))
1875-
unregister_netdevice_queue(geneve->dev, head);
1876-
}
1863+
list_for_each_entry_safe(geneve, next, &gn->geneve_list, next)
1864+
geneve_dellink(geneve->dev, head);
18771865
}
18781866

18791867
static void __net_exit geneve_exit_batch_rtnl(struct list_head *net_list,

drivers/net/vxlan/vxlan_core.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,10 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
14631463
if (likely(f)) {
14641464
struct vxlan_rdst *rdst = first_remote_rcu(f);
14651465

1466+
/* Don't override an fdb with nexthop with a learnt entry */
1467+
if (rcu_access_pointer(f->nh))
1468+
return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
1469+
14661470
if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) &&
14671471
rdst->remote_ifindex == ifindex))
14681472
return SKB_NOT_DROPPED_YET;
@@ -1471,10 +1475,6 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
14711475
if (f->state & (NUD_PERMANENT | NUD_NOARP))
14721476
return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
14731477

1474-
/* Don't override an fdb with nexthop with a learnt entry */
1475-
if (rcu_access_pointer(f->nh))
1476-
return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
1477-
14781478
if (net_ratelimit())
14791479
netdev_info(dev,
14801480
"%pM migrated from %pIS to %pIS\n",
@@ -1908,6 +1908,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
19081908
n = neigh_lookup(&arp_tbl, &tip, dev);
19091909

19101910
if (n) {
1911+
struct vxlan_rdst *rdst = NULL;
19111912
struct vxlan_fdb *f;
19121913
struct sk_buff *reply;
19131914

@@ -1916,12 +1917,17 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
19161917
goto out;
19171918
}
19181919

1920+
rcu_read_lock();
19191921
f = vxlan_find_mac(vxlan, n->ha, vni);
1920-
if (f && vxlan_addr_any(&(first_remote_rcu(f)->remote_ip))) {
1922+
if (f)
1923+
rdst = first_remote_rcu(f);
1924+
if (rdst && vxlan_addr_any(&rdst->remote_ip)) {
19211925
/* bridge-local neighbor */
19221926
neigh_release(n);
1927+
rcu_read_unlock();
19231928
goto out;
19241929
}
1930+
rcu_read_unlock();
19251931

19261932
reply = arp_create(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha,
19271933
n->ha, sha);
@@ -2072,6 +2078,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
20722078
n = neigh_lookup(ipv6_stub->nd_tbl, &msg->target, dev);
20732079

20742080
if (n) {
2081+
struct vxlan_rdst *rdst = NULL;
20752082
struct vxlan_fdb *f;
20762083
struct sk_buff *reply;
20772084

@@ -2081,7 +2088,9 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
20812088
}
20822089

20832090
f = vxlan_find_mac(vxlan, n->ha, vni);
2084-
if (f && vxlan_addr_any(&(first_remote_rcu(f)->remote_ip))) {
2091+
if (f)
2092+
rdst = first_remote_rcu(f);
2093+
if (rdst && vxlan_addr_any(&rdst->remote_ip)) {
20852094
/* bridge-local neighbor */
20862095
neigh_release(n);
20872096
goto out;
@@ -2638,14 +2647,10 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev,
26382647
memset(&nh_rdst, 0, sizeof(struct vxlan_rdst));
26392648
hash = skb_get_hash(skb);
26402649

2641-
rcu_read_lock();
26422650
nh = rcu_dereference(f->nh);
2643-
if (!nh) {
2644-
rcu_read_unlock();
2651+
if (!nh)
26452652
goto drop;
2646-
}
26472653
do_xmit = vxlan_fdb_nh_path_select(nh, hash, &nh_rdst);
2648-
rcu_read_unlock();
26492654

26502655
if (likely(do_xmit))
26512656
vxlan_xmit_one(skb, dev, vni, &nh_rdst, did_rsc);
@@ -2772,6 +2777,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
27722777
}
27732778

27742779
eth = eth_hdr(skb);
2780+
rcu_read_lock();
27752781
f = vxlan_find_mac(vxlan, eth->h_dest, vni);
27762782
did_rsc = false;
27772783

@@ -2794,7 +2800,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
27942800
vxlan_vnifilter_count(vxlan, vni, NULL,
27952801
VXLAN_VNI_STATS_TX_DROPS, 0);
27962802
kfree_skb_reason(skb, SKB_DROP_REASON_NO_TX_TARGET);
2797-
return NETDEV_TX_OK;
2803+
goto out;
27982804
}
27992805
}
28002806

@@ -2819,6 +2825,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
28192825
kfree_skb_reason(skb, SKB_DROP_REASON_NO_TX_TARGET);
28202826
}
28212827

2828+
out:
2829+
rcu_read_unlock();
28222830
return NETDEV_TX_OK;
28232831
}
28242832

drivers/net/vxlan/vxlan_private.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ static inline struct hlist_head *vs_head(struct net *net, __be16 port)
5656
return &vn->sock_list[hash_32(ntohs(port), PORT_HASH_BITS)];
5757
}
5858

59-
/* First remote destination for a forwarding entry.
60-
* Guaranteed to be non-NULL because remotes are never deleted.
61-
*/
59+
/* First remote destination for a forwarding entry. */
6260
static inline struct vxlan_rdst *first_remote_rcu(struct vxlan_fdb *fdb)
6361
{
6462
if (rcu_access_pointer(fdb->nh))

drivers/net/vxlan/vxlan_vnifilter.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,14 +627,20 @@ static void vxlan_vni_delete_group(struct vxlan_dev *vxlan,
627627
* default dst remote_ip previously added for this vni
628628
*/
629629
if (!vxlan_addr_any(&vninode->remote_ip) ||
630-
!vxlan_addr_any(&dst->remote_ip))
630+
!vxlan_addr_any(&dst->remote_ip)) {
631+
u32 hash_index = fdb_head_index(vxlan, all_zeros_mac,
632+
vninode->vni);
633+
634+
spin_lock_bh(&vxlan->hash_lock[hash_index]);
631635
__vxlan_fdb_delete(vxlan, all_zeros_mac,
632636
(vxlan_addr_any(&vninode->remote_ip) ?
633637
dst->remote_ip : vninode->remote_ip),
634638
vxlan->cfg.dst_port,
635639
vninode->vni, vninode->vni,
636640
dst->remote_ifindex,
637641
true);
642+
spin_unlock_bh(&vxlan->hash_lock[hash_index]);
643+
}
638644

639645
if (vxlan->dev->flags & IFF_UP) {
640646
if (vxlan_addr_multicast(&vninode->remote_ip) &&

0 commit comments

Comments
 (0)