Skip to content

Commit ae67b96

Browse files
netoptimizerkernel-patches-bot
authored andcommitted
bpf: drop MTU check when doing TC-BPF redirect to ingress
The use-case for dropping the MTU check when TC-BPF ingress redirecting a packet, is described by Eyal Birger in email[0]. The summary is the ability to increase packet size (e.g. with IPv6 headers for NAT64) and ingress redirect packet and let normal netstack fragment packet as needed. [0] https://lore.kernel.org/netdev/CAHsH6Gug-hsLGHQ6N0wtixdOa85LDZ3HNRHVd0opR=19Qo4W4Q@mail.gmail.com/ Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
1 parent 709cc55 commit ae67b96

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

include/linux/netdevice.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3866,10 +3866,11 @@ bool is_skb_forwardable(const struct net_device *dev,
38663866
const struct sk_buff *skb);
38673867

38683868
static __always_inline int ____dev_forward_skb(struct net_device *dev,
3869-
struct sk_buff *skb)
3869+
struct sk_buff *skb,
3870+
const bool mtu_check)
38703871
{
38713872
if (skb_orphan_frags(skb, GFP_ATOMIC) ||
3872-
unlikely(!is_skb_forwardable(dev, skb))) {
3873+
(mtu_check && unlikely(!is_skb_forwardable(dev, skb)))) {
38733874
atomic_long_inc(&dev->rx_dropped);
38743875
kfree_skb(skb);
38753876
return NET_RX_DROP;

net/core/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,7 @@ EXPORT_SYMBOL_GPL(is_skb_forwardable);
22092209

22102210
int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
22112211
{
2212-
int ret = ____dev_forward_skb(dev, skb);
2212+
int ret = ____dev_forward_skb(dev, skb, true);
22132213

22142214
if (likely(!ret)) {
22152215
skb->protocol = eth_type_trans(skb, dev);

net/core/filter.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,13 +2083,21 @@ static const struct bpf_func_proto bpf_csum_level_proto = {
20832083

20842084
static inline int __bpf_rx_skb(struct net_device *dev, struct sk_buff *skb)
20852085
{
2086-
return dev_forward_skb(dev, skb);
2086+
int ret = ____dev_forward_skb(dev, skb, false);
2087+
2088+
if (likely(!ret)) {
2089+
skb->protocol = eth_type_trans(skb, dev);
2090+
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
2091+
ret = netif_rx(skb);
2092+
}
2093+
2094+
return ret;
20872095
}
20882096

20892097
static inline int __bpf_rx_skb_no_mac(struct net_device *dev,
20902098
struct sk_buff *skb)
20912099
{
2092-
int ret = ____dev_forward_skb(dev, skb);
2100+
int ret = ____dev_forward_skb(dev, skb, false);
20932101

20942102
if (likely(!ret)) {
20952103
skb->dev = dev;

0 commit comments

Comments
 (0)