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 via email to