Skip to content

Commit 5418f60

Browse files
author
CKI KWF Bot
committed
Merge: net/other: phase-1 backports for rhel-10.2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1612 JIRA: https://issues.redhat.com/browse/RHEL-115601 Upstream Status: all mainline in net.git Tested: boot-tested only Conflicts: None Signed-off-by: Davide Caratti <dcaratti@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: Antoine Tenart <atenart@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 cdaa432 + 1576919 commit 5418f60

File tree

4 files changed

+67
-29
lines changed

4 files changed

+67
-29
lines changed

drivers/net/loopback.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,22 @@ static netdev_tx_t blackhole_netdev_xmit(struct sk_buff *skb,
244244
return NETDEV_TX_OK;
245245
}
246246

247+
static int blackhole_neigh_output(struct neighbour *n, struct sk_buff *skb)
248+
{
249+
kfree_skb(skb);
250+
return 0;
251+
}
252+
253+
static int blackhole_neigh_construct(struct net_device *dev,
254+
struct neighbour *n)
255+
{
256+
n->output = blackhole_neigh_output;
257+
return 0;
258+
}
259+
247260
static const struct net_device_ops blackhole_netdev_ops = {
248261
.ndo_start_xmit = blackhole_netdev_xmit,
262+
.ndo_neigh_construct = blackhole_neigh_construct,
249263
};
250264

251265
/* This is a dst-dummy device used specifically for invalidated

net/8021q/vlan.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,35 @@ static int __vlan_device_event(struct net_device *dev, unsigned long event)
358358
return err;
359359
}
360360

361+
static void vlan_vid0_add(struct net_device *dev)
362+
{
363+
struct vlan_info *vlan_info;
364+
int err;
365+
366+
if (!(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER))
367+
return;
368+
369+
pr_info("adding VLAN 0 to HW filter on device %s\n", dev->name);
370+
371+
err = vlan_vid_add(dev, htons(ETH_P_8021Q), 0);
372+
if (err)
373+
return;
374+
375+
vlan_info = rtnl_dereference(dev->vlan_info);
376+
vlan_info->auto_vid0 = true;
377+
}
378+
379+
static void vlan_vid0_del(struct net_device *dev)
380+
{
381+
struct vlan_info *vlan_info = rtnl_dereference(dev->vlan_info);
382+
383+
if (!vlan_info || !vlan_info->auto_vid0)
384+
return;
385+
386+
vlan_info->auto_vid0 = false;
387+
vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
388+
}
389+
361390
static int vlan_device_event(struct notifier_block *unused, unsigned long event,
362391
void *ptr)
363392
{
@@ -379,15 +408,10 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
379408
return notifier_from_errno(err);
380409
}
381410

382-
if ((event == NETDEV_UP) &&
383-
(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) {
384-
pr_info("adding VLAN 0 to HW filter on device %s\n",
385-
dev->name);
386-
vlan_vid_add(dev, htons(ETH_P_8021Q), 0);
387-
}
388-
if (event == NETDEV_DOWN &&
389-
(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER))
390-
vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
411+
if (event == NETDEV_UP)
412+
vlan_vid0_add(dev);
413+
else if (event == NETDEV_DOWN)
414+
vlan_vid0_del(dev);
391415

392416
vlan_info = rtnl_dereference(dev->vlan_info);
393417
if (!vlan_info)

net/8021q/vlan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct vlan_info {
3333
struct vlan_group grp;
3434
struct list_head vid_list;
3535
unsigned int nr_vids;
36+
bool auto_vid0;
3637
struct rcu_head rcu;
3738
};
3839

net/packet/af_packet.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
27842784
int len_sum = 0;
27852785
int status = TP_STATUS_AVAILABLE;
27862786
int hlen, tlen, copylen = 0;
2787-
long timeo = 0;
2787+
long timeo;
27882788

27892789
mutex_lock(&po->pg_vec_lock);
27902790

@@ -2838,22 +2838,28 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
28382838
if ((size_max > dev->mtu + reserve + VLAN_HLEN) && !vnet_hdr_sz)
28392839
size_max = dev->mtu + reserve + VLAN_HLEN;
28402840

2841+
timeo = sock_sndtimeo(&po->sk, msg->msg_flags & MSG_DONTWAIT);
28412842
reinit_completion(&po->skb_completion);
28422843

28432844
do {
28442845
ph = packet_current_frame(po, &po->tx_ring,
28452846
TP_STATUS_SEND_REQUEST);
28462847
if (unlikely(ph == NULL)) {
2847-
if (need_wait && skb) {
2848-
timeo = sock_sndtimeo(&po->sk, msg->msg_flags & MSG_DONTWAIT);
2848+
/* Note: packet_read_pending() might be slow if we
2849+
* have to call it as it's per_cpu variable, but in
2850+
* fast-path we don't have to call it, only when ph
2851+
* is NULL, we need to check the pending_refcnt.
2852+
*/
2853+
if (need_wait && packet_read_pending(&po->tx_ring)) {
28492854
timeo = wait_for_completion_interruptible_timeout(&po->skb_completion, timeo);
28502855
if (timeo <= 0) {
28512856
err = !timeo ? -ETIMEDOUT : -ERESTARTSYS;
28522857
goto out_put;
28532858
}
2854-
}
2855-
/* check for additional frames */
2856-
continue;
2859+
/* check for additional frames */
2860+
continue;
2861+
} else
2862+
break;
28572863
}
28582864

28592865
skb = NULL;
@@ -2942,14 +2948,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
29422948
}
29432949
packet_increment_head(&po->tx_ring);
29442950
len_sum += tp_len;
2945-
} while (likely((ph != NULL) ||
2946-
/* Note: packet_read_pending() might be slow if we have
2947-
* to call it as it's per_cpu variable, but in fast-path
2948-
* we already short-circuit the loop with the first
2949-
* condition, and luckily don't have to go that path
2950-
* anyway.
2951-
*/
2952-
(need_wait && packet_read_pending(&po->tx_ring))));
2951+
} while (1);
29532952

29542953
err = len_sum;
29552954
goto out_put;
@@ -4563,10 +4562,10 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
45634562
spin_lock(&po->bind_lock);
45644563
was_running = packet_sock_flag(po, PACKET_SOCK_RUNNING);
45654564
num = po->num;
4566-
if (was_running) {
4567-
WRITE_ONCE(po->num, 0);
4565+
WRITE_ONCE(po->num, 0);
4566+
if (was_running)
45684567
__unregister_prot_hook(sk, false);
4569-
}
4568+
45704569
spin_unlock(&po->bind_lock);
45714570

45724571
synchronize_net();
@@ -4598,10 +4597,10 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
45984597
mutex_unlock(&po->pg_vec_lock);
45994598

46004599
spin_lock(&po->bind_lock);
4601-
if (was_running) {
4602-
WRITE_ONCE(po->num, num);
4600+
WRITE_ONCE(po->num, num);
4601+
if (was_running)
46034602
register_prot_hook(sk);
4604-
}
4603+
46054604
spin_unlock(&po->bind_lock);
46064605
if (pg_vec && (po->tp_version > TPACKET_V2)) {
46074606
/* Because we don't support block-based V3 on tx-ring */

0 commit comments

Comments
 (0)