[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0dcf1824-5819-4280-828d-46cf5bce3527@lunn.ch>
Date: Fri, 8 Mar 2024 03:17:01 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Antonio Quartulli <antonio@...nvpn.net>
Cc: netdev@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>,
Sergey Ryazanov <ryazanov.s.a@...il.com>,
Paolo Abeni <pabeni@...hat.com>, Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH net-next v2 09/22] ovpn: implement basic RX path (UDP)
> +++ b/drivers/net/ovpn/io.c
> @@ -53,6 +53,113 @@ int ovpn_struct_init(struct net_device *dev)
> return 0;
> }
>
> +/* Called after decrypt to write IP packet to tun netdev.
> + * This method is expected to manage/free skb.
tun?
The userspace implementation uses tun, but being in the kernel, don't
you just pass it to the stack?
> + */
> +static void ovpn_netdev_write(struct ovpn_peer *peer, struct sk_buff *skb)
> +{
> + /* packet integrity was verified on the VPN layer - no need to perform
> + * any additional check along the stack
> + */
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> + skb->csum_level = ~0;
> +
> + /* skb hash for transport packet no longer valid after decapsulation */
> + skb_clear_hash(skb);
> +
> + /* post-decrypt scrub -- prepare to inject encapsulated packet onto tun
> + * interface, based on __skb_tunnel_rx() in dst.h
> + */
> + skb->dev = peer->ovpn->dev;
> + skb_set_queue_mapping(skb, 0);
> + skb_scrub_packet(skb, true);
> +
> + skb_reset_network_header(skb);
> + skb_reset_transport_header(skb);
> + skb_probe_transport_header(skb);
> + skb_reset_inner_headers(skb);
> +
> + /* update per-cpu RX stats with the stored size of encrypted packet */
> +
> + /* we are in softirq context - hence no locking nor disable preemption needed */
> + dev_sw_netstats_rx_add(peer->ovpn->dev, skb->len);
> +
> + /* cause packet to be "received" by tun interface */
> + napi_gro_receive(&peer->napi, skb);
> +}
> +
> +int ovpn_napi_poll(struct napi_struct *napi, int budget)
> +{
> + struct ovpn_peer *peer = container_of(napi, struct ovpn_peer, napi);
> + struct sk_buff *skb;
> + int work_done = 0;
> +
> + if (unlikely(budget <= 0))
> + return 0;
> + /* this function should schedule at most 'budget' number of
> + * packets for delivery to the tun interface.
More tun. Did you copy code from the tun driver?
Andrew
Powered by blists - more mailing lists