lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aGT7ALhW060Tv22l@gmail.com>
Date: Wed, 2 Jul 2025 02:25:20 -0700
From: Breno Leitao <leitao@...ian.org>
To: Jakub Kicinski <kuba@...nel.org>
Cc: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
	Simon Horman <horms@...nel.org>,
	Andrew Lunn <andrew+netdev@...n.ch>, Shuah Khan <shuah@...nel.org>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org, gustavold@...il.com
Subject: Re: [PATCH net-next 6/7] netpoll: move Ethernet setup to push_eth()
 helper

On Tue, Jul 01, 2025 at 05:53:25PM -0700, Jakub Kicinski wrote:
> On Fri, 27 Jun 2025 10:55:52 -0700 Breno Leitao wrote:
> > +static void push_eth(struct netpoll *np, struct sk_buff *skb)
> > +{
> > +	struct ethhdr *eth;
> > +
> > +	eth = eth_hdr(skb);
> > +	ether_addr_copy(eth->h_source, np->dev->dev_addr);
> > +	ether_addr_copy(eth->h_dest, np->remote_mac);
> > +}
> 
> Can you move the pushing of the header and setting h_proto here?
> 
> if the goal of the series is to slice up the code per network layer
> then its a bit odd for the IP layer handlers to be pushing the L2
> header and setting its proto.
> 
> Just:
> 
> 	if (np->ipv6)
> 		eth->h_proto = htons(ETH_P_IPV6);
> 	else
> 		eth->h_proto = htons(ETH_P_IP);
> 
> no?

yes. We can do it. In fact, if we want to do even better, we can move
the can move the skb_push(skb, ETH_HLEN) and skb_reset_mac_header() here
as well. This will slice up the code even better.

The function will look like the following:

	static void push_eth(struct netpoll *np, struct sk_buff *skb)
	{
		struct ethhdr *eth;

		eth = skb_push(skb, ETH_HLEN);
		skb_reset_mac_header(skb);
		ether_addr_copy(eth->h_source, np->dev->dev_addr);
		ether_addr_copy(eth->h_dest, np->remote_mac);
		if (np->ipv6)
			eth->h_proto = htons(ETH_P_IPV6);
		else
			eth->h_proto = htons(ETH_P_IP);
	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ