public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: netdev@vger.kernel.org,  "(JC),
	Jayachandran" <j-rameshbabu@ti.com>,
	 "David S. Miller" <davem@davemloft.net>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	 Chintan Vankar <c-vankar@ti.com>,
	 Danish Anwar <danishanwar@ti.com>,  Daolin Qiu <d-qiu@ti.com>,
	 Eric Dumazet <edumazet@google.com>,
	 Felix Maurer <fmaurer@redhat.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Richard Cochran <richardcochran@gmail.com>,
	 Simon Horman <horms@kernel.org>
Subject: Re: [PATCH RFC net-next v2 2/2] af_packet: Add port specific handling for HSR
Date: Thu, 12 Mar 2026 17:43:36 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.be379ee17449@gmail.com> (raw)
In-Reply-To: <20260312154253.UC-QUPvD@linutronix.de>

Sebastian Andrzej Siewior wrote:
> On 2026-03-10 17:35:33 [-0400], Willem de Bruijn wrote:
> > > but the problem was sending with system's HSR header.
> > >
> > > > For the first case, could skb->mark be used as port selector when
> > > > writing from a packet socket to the master device? That already works
> > > > with sock_cmsg_send.
> > > 
> > > We would have to specify that SO_MARK 1 and 2 denotes the port on which
> > > a packet is sent. This kind of burns the usage for everything else on
> > > HSR so it feels misused.
> > 
> > It is more or less what mark is for. An alternative similar field
> > supported by sock_cmsg_send is skb->priority.
> 
> The ->priority thing looks wrong. It is used by ssh and other
> application so they would suddenly behave differently.
> But okay lets take SO_MARK. Might be smallest abuse here.
> And we would have to hardcode the values in respect to HSR and I have no
> idea where to document this.
> The difference with SO_MARK in general (at least my understanding) is
> that you can choose the values based on your setup. Here we would say
> 7-0 are already reserved.
> 
> > An alternative may be to share the information in-band. Already
> > insert the HSR header also wen writing to the master device. If the
> > master device can detect this packet-with-pre-existing header.
> 
> Given all this, I guess it is easier to stick to SO_MARK as the header
> might collide with other data.

Inserting a header by the packet socket sender and popping it in
hsr_dev_xmit is a bit like virtio_net. It is a private channel.

The tricky part is how hsr_dev_xmit can differentiate such packets
inserted by a packet socket, from regular packets arriving on the
device.

Anyway, admittedly it is a bit of a hack too.


> > This is not the first case where ndo_start_xmit may already expect a
> > header prefixed that it normally inserts. I forgot the exact case (can
> > look it up), maybe a weird edge case in GRE?
> > 
> > It does not even have to be a valid HSR header: just an agreement
> > between the process writing the raw packet and hsr_dev_xmit.
> > 
> > There probably are still more ways we can approach this challenge.
> > But these are three that do not require kernel changes outside the
> > HSR protocol code.
> 
> Okay.
> 
> > > And then we would need an additional bit to
> > > specify whether the HSR header is there or not. Unless I open additional
> > > socket on the ethernet device just for sending and dropping everything
> > > incoming.
> > 
> > Right, packets that already have a header prefixed are written
> > directly to the intended slave.
> > 
> > > And we would have to filter/ distinguish the RX port based on it.
> > > Userland has a cBPF filter to filter everything out and receive only PTP
> > > frames. If the PTP packet is forwarded to both sockets (A and B) then
> > > userland would have to throw one copy away and go to sleep again. This
> > > sort of breaks currently linuxptp logic. It would probably require
> > > either eBPF to filter also so_mark or deal with "no packet despite the
> > > wakeup" but so far I tried minimal impact on both sides (kernel and
> > > user).
> > 
> > I don't fully follow this part. It discusses Rx again?
> 
> Yes, this is RX. If I open packet socket, bind to hsr0, how do I filter
> for packets from one of the slaves?

I was thinking of attaching directly to the slave devices.

> After some thinking and browsing through the packet code:
> The hsr stack creates hsrX. If it would create additionally hsrX_A and
> hsrX_B in order to be able to send and receive only on the relevant
> slave device then I wouldn't need the filters in packet code. That could
> work…

That's another option.

  reply	other threads:[~2026-03-12 21:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 15:52 [PATCH RFC net-next v2 0/2] hsr: Add additional info to send/ receive skbs Sebastian Andrzej Siewior
2026-03-09 15:52 ` [PATCH RFC net-next v2 1/2] hsr: Allow to send a specific port and with HSR header Sebastian Andrzej Siewior
2026-03-09 15:52 ` [PATCH RFC net-next v2 2/2] af_packet: Add port specific handling for HSR Sebastian Andrzej Siewior
2026-03-10  1:38   ` Willem de Bruijn
2026-03-10 10:55     ` Sebastian Andrzej Siewior
2026-03-10 21:35       ` Willem de Bruijn
2026-03-12 15:42         ` Sebastian Andrzej Siewior
2026-03-12 21:43           ` Willem de Bruijn [this message]
2026-03-13  9:22             ` Sebastian Andrzej Siewior
2026-03-13 16:04               ` Sebastian Andrzej Siewior
2026-03-16 20:12                 ` Willem de Bruijn
2026-03-17 17:29                   ` Sebastian Andrzej Siewior
2026-03-19 13:29                     ` Willem de Bruijn
2026-03-19 14:26                       ` Sebastian Andrzej Siewior
2026-03-19 16:27                         ` Willem de Bruijn
2026-03-24 16:38                           ` Sebastian Andrzej Siewior

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=willemdebruijn.kernel.be379ee17449@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=c-vankar@ti.com \
    --cc=d-qiu@ti.com \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fmaurer@redhat.com \
    --cc=horms@kernel.org \
    --cc=j-rameshbabu@ti.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox