All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, gustavold@gmail.com
Subject: Re: [PATCH net-next 6/7] netpoll: move Ethernet setup to push_eth() helper
Date: Wed, 2 Jul 2025 02:25:20 -0700	[thread overview]
Message-ID: <aGT7ALhW060Tv22l@gmail.com> (raw)
In-Reply-To: <20250701175325.5c1970b9@kernel.org>

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);
	}

  reply	other threads:[~2025-07-02  9:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 17:55 [PATCH net-next 0/7] netpoll: Factor out functions from netpoll_send_udp() and add ipv6 selftest Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 1/7] netpoll: Improve code clarity with explicit struct size calculations Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 2/7] netpoll: factor out UDP checksum calculation into helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 3/7] netpoll: factor out IPv6 header setup into push_ipv6() helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 4/7] netpoll: factor out IPv4 header setup into push_ipv4() helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 5/7] netpoll: factor out UDP header setup into push_udp() helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 6/7] netpoll: move Ethernet setup to push_eth() helper Breno Leitao
2025-07-02  0:53   ` Jakub Kicinski
2025-07-02  9:25     ` Breno Leitao [this message]
2025-06-27 17:55 ` [PATCH net-next 7/7] selftests: net: Add IPv6 support to netconsole basic tests Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aGT7ALhW060Tv22l@gmail.com \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavold@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.