Skip to contentSkip to conversation

ipv6: When forwarding count rx stats on the orig netdev

PATCH Applied Stephen Suryaputra 3 participants 9 messages Oct 14, 2021 – Oct 18, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: When forwarding count rx stats on the orig netdev

Commit bdb7cc643fc9 ("ipv6: Count interface receive statistics on the ingress netdev") does not work when ip6_forward() executes on the skbs with vrf-enslaved netdev. Use IP6CB(skb)->iif to get to the right one.

Add a selftest script to verify.

Fixes bdb7cc643fc9 ("ipv6: Count interface receive statistics on the ingress netdev")
---
 net/ipv6/ip6_output.c                         |   3 +-
 .../testing/selftests/net/forwarding/Makefile |   1 +
 .../net/forwarding/forwarding.config.sample   |   2 +
 .../net/forwarding/ip6_forward_instats_vrf.sh | 172 ++++++++++++++++++
 tools/testing/selftests/net/forwarding/lib.sh |   8 +
 5 files changed, 185 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/net/forwarding/ip6_forward_instats_vrf.sh
net/ipv6/ip6_output.c +2 -1
index 12f985f43bcc..2f044a49afa8 100644
@@ -464,13 +464,14 @@ static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
 
 int ip6_forward(struct sk_buff *skb)
 {
-	struct inet6_dev *idev = __in6_dev_get_safely(skb->dev);
 	struct dst_entry *dst = skb_dst(skb);
 	struct ipv6hdr *hdr = ipv6_hdr(skb);
 	struct inet6_skb_parm *opt = IP6CB(skb);
 	struct net *net = dev_net(dst->dev);
+	struct inet6_dev *idev;
 	u32 mtu;
 
+	idev = __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif));
 	if (net->ipv6.devconf_all->forwarding == 0)
 		goto error;
 
tools/testing/selftests/net/forwarding/Makefile +1 -0
index d97bd6889446..72ee644d47bf 100644
@@ -9,6 +9,7 @@ TEST_PROGS = bridge_igmp.sh \
 	gre_inner_v4_multipath.sh \
 	gre_inner_v6_multipath.sh \
 	gre_multipath.sh \
+	ip6_forward_instats_vrf.sh \
 	ip6gre_inner_v4_multipath.sh \
 	ip6gre_inner_v6_multipath.sh \
 	ipip_flat_gre_key.sh \
tools/testing/selftests/net/forwarding/forwarding.config.sample +2 -0
index b802c14d2950..e5e2fbeca22e 100644
@@ -39,3 +39,5 @@ NETIF_CREATE=yes
 # Timeout (in seconds) before ping exits regardless of how many packets have
 # been sent or received
 PING_TIMEOUT=5
+# IPv6 traceroute utility name.
+TROUTE6=traceroute6
tools/testing/selftests/net/forwarding/ip6_forward_instats_vrf.sh new file +172 -0

172 lines not on this page · raw message

tools/testing/selftests/net/forwarding/lib.sh +8 -0
index e7fc5c35b569..92087d423bcf 100644
@@ -751,6 +751,14 @@ qdisc_parent_stats_get()
 	    | jq '.[] | select(.parent == "'"$parent"'") | '"$selector"
 }
 
+ipv6_stats_get()
+{
+	local dev=$1; shift
+	local stat=$1; shift
+
+	cat /proc/net/dev_snmp6/$dev | grep "^$stat" | cut -f2
+}
+
 humanize()
 {
 	local speed=$1; shift
Signature · 1 line
2.25.1
#1 lore raw

[ added Ido for the forwarding tests ]

Quoted 27 lines · Stephen Suryaputra

Commit bdb7cc643fc9 ("ipv6: Count interface receive statistics on the ingress netdev") does not work when ip6_forward() executes on the skbs with vrf-enslaved netdev. Use IP6CB(skb)->iif to get to the right one.

Add a selftest script to verify.

Fixes bdb7cc643fc9 ("ipv6: Count interface receive statistics on the ingress netdev")
---
 net/ipv6/ip6_output.c                         |   3 +-
 .../testing/selftests/net/forwarding/Makefile |   1 +
 .../net/forwarding/forwarding.config.sample   |   2 +
 .../net/forwarding/ip6_forward_instats_vrf.sh | 172 ++++++++++++++++++
 tools/testing/selftests/net/forwarding/lib.sh |   8 +
 5 files changed, 185 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/net/forwarding/ip6_forward_instats_vrf.sh
net/ipv6/ip6_output.c +0 -1
index 12f985f43bcc..2f044a49afa8 100644
@@ -464,13 +464,14 @@ static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
 
 int ip6_forward(struct sk_buff *skb)
 {
-	struct inet6_dev *idev = __in6_dev_get_safely(skb->dev);
 	struct dst_entry *dst = skb_dst(skb);

net/ipv6/ip6_output.c static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu) · line 477

Quoted 10 lines
net/ipv6/ip6_output.c +2 -0
 	struct ipv6hdr *hdr = ipv6_hdr(skb);
 	struct inet6_skb_parm *opt = IP6CB(skb);
 	struct net *net = dev_net(dst->dev);
+	struct inet6_dev *idev;
 	u32 mtu;
 
+	idev = __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif));
 	if (net->ipv6.devconf_all->forwarding == 0)
 		goto error;
 

This seems fine to me, but IPv4 and IPv6 should work the same.

#2 lore raw
Quoted 2 lines · David Ahern

[ added Ido for the forwarding tests ]

[snip]

Quoted 2 lines

This seems fine to me, but IPv4 and IPv6 should work the same.

But we don't have per if ipv4 stats. Remember that I tried to get something going but wasn't getting any traction?

#3 lore raw
Quoted 10 lines · Stephen Suryaputra
Quoted 2 lines · David Ahern

[ added Ido for the forwarding tests ]

[snip]

Quoted 2 lines

This seems fine to me, but IPv4 and IPv6 should work the same.

But we don't have per if ipv4 stats. Remember that I tried to get something going but wasn't getting any traction?

oh right, ipv4 is per net-namespace.

maintainer
#4 lore raw
Quoted 4 lines · On Thu, 14 Oct 2021 20:27:38 -0600 David Ahern wrote:
Quoted 3 lines · Stephen Suryaputra
Quoted 2 lines · David Ahern

[ added Ido for the forwarding tests ]

Quoted 8 lines
Quoted 7 lines

[snip]

Quoted 2 lines

This seems fine to me, but IPv4 and IPv6 should work the same.

But we don't have per if ipv4 stats. Remember that I tried to get something going but wasn't getting any traction?

oh right, ipv4 is per net-namespace.

Is that an ack? :)

Reviewed-by
#5 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 14 Oct 2021 20:27:38 -0600 David Ahern wrote:
Quoted 5 lines · Stephen Suryaputra
Quoted 2 lines · David Ahern

[ added Ido for the forwarding tests ]

[snip]

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

This seems fine to me, but IPv4 and IPv6 should work the same.

But we don't have per if ipv4 stats. Remember that I tried to get something going but wasn't getting any traction?

oh right, ipv4 is per net-namespace.

Is that an ack? :)

maintainer Applied
#6 lore raw
Quoted 5 lines · On Fri, 15 Oct 2021 15:28:00 -0600 David Ahern wrote:
Quoted 3 lines
Quoted 1 line

oh right, ipv4 is per net-namespace.

Is that an ack? :)

Thanks, applied!

#7 lore raw

Could this patch be queued for -stable?
Thank you.

Quoted 9 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 15 Oct 2021 15:28:00 -0600 David Ahern wrote:
Quoted 3 lines
Quoted 1 line

oh right, ipv4 is per net-namespace.

Is that an ack? :)

Thanks, applied!

maintainer
#8 lore raw
Quoted 1 line · On Mon, 18 Oct 2021 09:24:21 -0400 Stephen Suryaputra wrote:

Could this patch be queued for -stable?

It will happen automatically based on the Fixes tag.