Skip to content

Commit 7b2e1fc

Browse files
author
CKI KWF Bot
committed
Merge: net/other: phase-2 backports for rhel-9.8
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7498 JIRA: https://issues.redhat.com/browse/RHEL-115650 Upstream Status: all mainline in net.git Tested: boot-tested only Conflicts: None Signed-off-by: Davide Caratti <dcaratti@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: Eder Zulian <ezulian@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 f800ad7 + 723c4bc commit 7b2e1fc

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
@@ -247,8 +247,22 @@ static netdev_tx_t blackhole_netdev_xmit(struct sk_buff *skb,
247247
return NETDEV_TX_OK;
248248
}
249249

250+
static int blackhole_neigh_output(struct neighbour *n, struct sk_buff *skb)
251+
{
252+
kfree_skb(skb);
253+
return 0;
254+
}
255+
256+
static int blackhole_neigh_construct(struct net_device *dev,
257+
struct neighbour *n)
258+
{
259+
n->output = blackhole_neigh_output;
260+
return 0;
261+
}
262+
250263
static const struct net_device_ops blackhole_netdev_ops = {
251264
.ndo_start_xmit = blackhole_netdev_xmit,
265+
.ndo_neigh_construct = blackhole_neigh_construct,
252266
};
253267

254268
/* 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
@@ -2741,7 +2741,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
27412741
int len_sum = 0;
27422742
int status = TP_STATUS_AVAILABLE;
27432743
int hlen, tlen, copylen = 0;
2744-
long timeo = 0;
2744+
long timeo;
27452745

27462746
mutex_lock(&po->pg_vec_lock);
27472747

@@ -2796,22 +2796,28 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
27962796
!packet_sock_flag(po, PACKET_SOCK_HAS_VNET_HDR))
27972797
size_max = dev->mtu + reserve + VLAN_HLEN;
27982798

2799+
timeo = sock_sndtimeo(&po->sk, msg->msg_flags & MSG_DONTWAIT);
27992800
reinit_completion(&po->skb_completion);
28002801

28012802
do {
28022803
ph = packet_current_frame(po, &po->tx_ring,
28032804
TP_STATUS_SEND_REQUEST);
28042805
if (unlikely(ph == NULL)) {
2805-
if (need_wait && skb) {
2806-
timeo = sock_sndtimeo(&po->sk, msg->msg_flags & MSG_DONTWAIT);
2806+
/* Note: packet_read_pending() might be slow if we
2807+
* have to call it as it's per_cpu variable, but in
2808+
* fast-path we don't have to call it, only when ph
2809+
* is NULL, we need to check the pending_refcnt.
2810+
*/
2811+
if (need_wait && packet_read_pending(&po->tx_ring)) {
28072812
timeo = wait_for_completion_interruptible_timeout(&po->skb_completion, timeo);
28082813
if (timeo <= 0) {
28092814
err = !timeo ? -ETIMEDOUT : -ERESTARTSYS;
28102815
goto out_put;
28112816
}
2812-
}
2813-
/* check for additional frames */
2814-
continue;
2817+
/* check for additional frames */
2818+
continue;
2819+
} else
2820+
break;
28152821
}
28162822

28172823
skb = NULL;
@@ -2900,14 +2906,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
29002906
}
29012907
packet_increment_head(&po->tx_ring);
29022908
len_sum += tp_len;
2903-
} while (likely((ph != NULL) ||
2904-
/* Note: packet_read_pending() might be slow if we have
2905-
* to call it as it's per_cpu variable, but in fast-path
2906-
* we already short-circuit the loop with the first
2907-
* condition, and luckily don't have to go that path
2908-
* anyway.
2909-
*/
2910-
(need_wait && packet_read_pending(&po->tx_ring))));
2909+
} while (1);
29112910

29122911
err = len_sum;
29132912
goto out_put;
@@ -4501,10 +4500,10 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
45014500
spin_lock(&po->bind_lock);
45024501
was_running = packet_sock_flag(po, PACKET_SOCK_RUNNING);
45034502
num = po->num;
4504-
if (was_running) {
4505-
WRITE_ONCE(po->num, 0);
4503+
WRITE_ONCE(po->num, 0);
4504+
if (was_running)
45064505
__unregister_prot_hook(sk, false);
4507-
}
4506+
45084507
spin_unlock(&po->bind_lock);
45094508

45104509
synchronize_net();
@@ -4536,10 +4535,10 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
45364535
mutex_unlock(&po->pg_vec_lock);
45374536

45384537
spin_lock(&po->bind_lock);
4539-
if (was_running) {
4540-
WRITE_ONCE(po->num, num);
4538+
WRITE_ONCE(po->num, num);
4539+
if (was_running)
45414540
register_prot_hook(sk);
4542-
}
4541+
45434542
spin_unlock(&po->bind_lock);
45444543
if (pg_vec && (po->tp_version > TPACKET_V2)) {
45454544
/* Because we don't support block-based V3 on tx-ring */

0 commit comments

Comments
 (0)