Re: [PATCH] ipv4: add sysctl knob to control the discarding of skb from local in ip_forward

From: Florian Westphal
Date: Tue Nov 09 2021 - 06:46:29 EST


Changliang Wu <changliang.wu@xxxxxxxxxx> wrote:
> This change is meant to add a control for forwarding skb from local.
> By default, ip forward will not receive the pakcet to/from the local.
> But in some special cases, for example:
> -
> | ovs-bridge gw-port | <----> kube-proxy(iptables) |
> -
> Ovs sends the packet to the gateway, which requires iptables for nat,
> such as kube-proxy (iptables), and then sends it back to the gateway
> through routing for further processing in ovs.

This a very terse description. How does packet end up in forward
after skb->sk assignment?

> diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
> index 00ec819..06b7e00 100644
> --- a/net/ipv4/ip_forward.c
> +++ b/net/ipv4/ip_forward.c
> @@ -95,9 +95,6 @@ int ip_forward(struct sk_buff *skb)
> if (skb->pkt_type != PACKET_HOST)
> goto drop;
>
> - if (unlikely(skb->sk))
> - goto drop;
> -

Please have a look at
2ab957492d13bb819400ac29ae55911d50a82a13

you need to explain why this is now ok.

Without explanation i have to assume stack will now crash again
when net->ipv4.sysctl_ip_fwd_accept_local=1 and TW socket is assigned.