Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC PATCH] net: bridge: Don't reset time stamps on SO_TXTIME enabled sockets
@ 2020-08-20 10:57 Kurt Kanzenbach
2020-08-20 11:23 ` Nikolay Aleksandrov
0 siblings, 1 reply; 3+ messages in thread
From: Kurt Kanzenbach @ 2020-08-20 10:57 UTC (permalink / raw)
To: Roopa Prabhu, Nikolay Aleksandrov
Cc: David S. Miller, Jakub Kicinski, bridge, netdev, Kurt Kanzenbach
When using the ETF Qdisc in combination with a bridge and DSA, then all packets
gets dropped due to invalid time stamps. The setup looks like this:
Transmit path:
Application -> bridge (br0) -> DSA slave ports (lan0, lan1) -> ETF Qdisc
-> ethernet (eth0)
The user space application uses SO_TXTIME to attach a sending time stamp for
each packet using the corresponding interface. That time stamp is then attached
to the skb in the kernel. The first network device involved in the chain is the
bridge device. However, in br_forward_finish() the time stamp is reset to zero
unconditionally. Meaning when the skb arrives at the ETF Qdisc, it's dropped as
invalid because the time stamp is zero.
The reset of the time stamp in the bridge code is there for a good reason. See
commit 41d1c8839e5f ("net: clear skb->tstamp in bridge forwarding path")
Therefore, add a conditional for SO_TXTIME enabled sockets.
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
net/bridge/br_forward.c | 9 +++++++++
1 file changed, 9 insertions(+)
RFC, because I don't know if that's the correct way to solve that issue.
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 7629b63f6f30..e5f7e49ed91d 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -15,6 +15,7 @@
#include <linux/skbuff.h>
#include <linux/if_vlan.h>
#include <linux/netfilter_bridge.h>
+#include <net/sock.h>
#include "br_private.h"
/* Don't forward packets to originating port or forwarding disabled */
@@ -61,7 +62,15 @@ EXPORT_SYMBOL_GPL(br_dev_queue_push_xmit);
int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{
+ /* When applications provide time stamps for packets via SO_TXTIME
+ * socket option, then don't reset it.
+ */
+ if (skb->sk && sock_flag(skb->sk, SOCK_TXTIME))
+ goto finish;
+
skb->tstamp = 0;
+
+finish:
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING,
net, sk, skb, NULL, skb->dev,
br_dev_queue_push_xmit);
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] net: bridge: Don't reset time stamps on SO_TXTIME enabled sockets
2020-08-20 10:57 [RFC PATCH] net: bridge: Don't reset time stamps on SO_TXTIME enabled sockets Kurt Kanzenbach
@ 2020-08-20 11:23 ` Nikolay Aleksandrov
2020-08-21 7:47 ` Kurt Kanzenbach
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Aleksandrov @ 2020-08-20 11:23 UTC (permalink / raw)
To: Kurt Kanzenbach, Roopa Prabhu
Cc: David S. Miller, Jakub Kicinski, bridge, netdev
On 8/20/20 1:57 PM, Kurt Kanzenbach wrote:
> When using the ETF Qdisc in combination with a bridge and DSA, then all packets
> gets dropped due to invalid time stamps. The setup looks like this:
>
> Transmit path:
>
> Application -> bridge (br0) -> DSA slave ports (lan0, lan1) -> ETF Qdisc
> -> ethernet (eth0)
>
> The user space application uses SO_TXTIME to attach a sending time stamp for
> each packet using the corresponding interface. That time stamp is then attached
> to the skb in the kernel. The first network device involved in the chain is the
> bridge device. However, in br_forward_finish() the time stamp is reset to zero
> unconditionally. Meaning when the skb arrives at the ETF Qdisc, it's dropped as
> invalid because the time stamp is zero.
>
> The reset of the time stamp in the bridge code is there for a good reason. See
> commit 41d1c8839e5f ("net: clear skb->tstamp in bridge forwarding path")
> Therefore, add a conditional for SO_TXTIME enabled sockets.
>
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
> net/bridge/br_forward.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> RFC, because I don't know if that's the correct way to solve that issue.
>
The new conditionals will be for all forwarded packets, not only the ones that are transmitted through
the bridge master device. If you'd like to do this please limit it to the bridge dev transmit.
Thanks,
Nik
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] net: bridge: Don't reset time stamps on SO_TXTIME enabled sockets
2020-08-20 11:23 ` Nikolay Aleksandrov
@ 2020-08-21 7:47 ` Kurt Kanzenbach
0 siblings, 0 replies; 3+ messages in thread
From: Kurt Kanzenbach @ 2020-08-21 7:47 UTC (permalink / raw)
To: Nikolay Aleksandrov, Roopa Prabhu
Cc: David S. Miller, Jakub Kicinski, bridge, netdev
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
On Thu Aug 20 2020, Nikolay Aleksandrov wrote:
> The new conditionals will be for all forwarded packets, not only the
> ones that are transmitted through the bridge master device.
I see makes sense.
> If you'd like to do this please limit it to the bridge dev transmit.
I'm wondering how to do that. The problem is that the time stamp is
reset to zero unconditionally in br_forward_finish(). This function is
also called in the transmit path.
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-21 7:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 10:57 [RFC PATCH] net: bridge: Don't reset time stamps on SO_TXTIME enabled sockets Kurt Kanzenbach
2020-08-20 11:23 ` Nikolay Aleksandrov
2020-08-21 7:47 ` Kurt Kanzenbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).