Message ID | 20230512152607.992209-14-larysa.zaremba@intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | new kfunc XDP hints and ice implementation | expand |
On 05/12, Larysa Zaremba wrote: > Make VLAN c-tag and s-tag XDP hint testing more convenient > by not skipping VLAN-ed packets. > > Allow both 802.1ad and 802.1Q headers. Can we also extend non-hw test? That should require adding metadata handlers to veth to extract relevant parts from skb + update ip link commands to add vlan id. Should be relatively easy to do? > > Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> > --- > tools/testing/selftests/bpf/progs/xdp_hw_metadata.c | 9 ++++++++- > tools/testing/selftests/bpf/xdp_metadata.h | 8 ++++++++ > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > index b2dfd7066c6e..f95f82a8b449 100644 > --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > @@ -26,15 +26,22 @@ int rx(struct xdp_md *ctx) > { > void *data, *data_meta, *data_end; > struct ipv6hdr *ip6h = NULL; > - struct ethhdr *eth = NULL; > struct udphdr *udp = NULL; > struct iphdr *iph = NULL; > struct xdp_meta *meta; > + struct ethhdr *eth; > int err; > > data = (void *)(long)ctx->data; > data_end = (void *)(long)ctx->data_end; > eth = data; > + > + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021AD)) > + eth = (void *)eth + sizeof(struct vlan_hdr); > + > + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021Q)) > + eth = (void *)eth + sizeof(struct vlan_hdr); > + > if (eth + 1 < data_end) { > if (eth->h_proto == bpf_htons(ETH_P_IP)) { > iph = (void *)(eth + 1); > diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h > index 938a729bd307..6664893c2c77 100644 > --- a/tools/testing/selftests/bpf/xdp_metadata.h > +++ b/tools/testing/selftests/bpf/xdp_metadata.h > @@ -9,6 +9,14 @@ > #define ETH_P_IPV6 0x86DD > #endif > > +#ifndef ETH_P_8021Q > +#define ETH_P_8021Q 0x8100 > +#endif > + > +#ifndef ETH_P_8021AD > +#define ETH_P_8021AD 0x88A8 > +#endif > + > struct xdp_meta { > __u64 rx_timestamp; > __u64 xdp_timestamp; > -- > 2.35.3 >
On Fri, May 12, 2023 at 11:33:34AM -0700, Stanislav Fomichev wrote: > On 05/12, Larysa Zaremba wrote: > > Make VLAN c-tag and s-tag XDP hint testing more convenient > > by not skipping VLAN-ed packets. > > > > Allow both 802.1ad and 802.1Q headers. > > Can we also extend non-hw test? That should require adding metadata > handlers to veth to extract relevant parts from skb + update ip link > commands to add vlan id. Should be relatively easy to do? > Seems like something I can and should do. Will be in v2. > > > > Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> > > --- > > tools/testing/selftests/bpf/progs/xdp_hw_metadata.c | 9 ++++++++- > > tools/testing/selftests/bpf/xdp_metadata.h | 8 ++++++++ > > 2 files changed, 16 insertions(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > > index b2dfd7066c6e..f95f82a8b449 100644 > > --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > > +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > > @@ -26,15 +26,22 @@ int rx(struct xdp_md *ctx) > > { > > void *data, *data_meta, *data_end; > > struct ipv6hdr *ip6h = NULL; > > - struct ethhdr *eth = NULL; > > struct udphdr *udp = NULL; > > struct iphdr *iph = NULL; > > struct xdp_meta *meta; > > + struct ethhdr *eth; > > int err; > > > > data = (void *)(long)ctx->data; > > data_end = (void *)(long)ctx->data_end; > > eth = data; > > + > > + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021AD)) > > + eth = (void *)eth + sizeof(struct vlan_hdr); > > + > > + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021Q)) > > + eth = (void *)eth + sizeof(struct vlan_hdr); > > + > > if (eth + 1 < data_end) { > > if (eth->h_proto == bpf_htons(ETH_P_IP)) { > > iph = (void *)(eth + 1); > > diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h > > index 938a729bd307..6664893c2c77 100644 > > --- a/tools/testing/selftests/bpf/xdp_metadata.h > > +++ b/tools/testing/selftests/bpf/xdp_metadata.h > > @@ -9,6 +9,14 @@ > > #define ETH_P_IPV6 0x86DD > > #endif > > > > +#ifndef ETH_P_8021Q > > +#define ETH_P_8021Q 0x8100 > > +#endif > > + > > +#ifndef ETH_P_8021AD > > +#define ETH_P_8021AD 0x88A8 > > +#endif > > + > > struct xdp_meta { > > __u64 rx_timestamp; > > __u64 xdp_timestamp; > > -- > > 2.35.3 > >
diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c index b2dfd7066c6e..f95f82a8b449 100644 --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c @@ -26,15 +26,22 @@ int rx(struct xdp_md *ctx) { void *data, *data_meta, *data_end; struct ipv6hdr *ip6h = NULL; - struct ethhdr *eth = NULL; struct udphdr *udp = NULL; struct iphdr *iph = NULL; struct xdp_meta *meta; + struct ethhdr *eth; int err; data = (void *)(long)ctx->data; data_end = (void *)(long)ctx->data_end; eth = data; + + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021AD)) + eth = (void *)eth + sizeof(struct vlan_hdr); + + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021Q)) + eth = (void *)eth + sizeof(struct vlan_hdr); + if (eth + 1 < data_end) { if (eth->h_proto == bpf_htons(ETH_P_IP)) { iph = (void *)(eth + 1); diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h index 938a729bd307..6664893c2c77 100644 --- a/tools/testing/selftests/bpf/xdp_metadata.h +++ b/tools/testing/selftests/bpf/xdp_metadata.h @@ -9,6 +9,14 @@ #define ETH_P_IPV6 0x86DD #endif +#ifndef ETH_P_8021Q +#define ETH_P_8021Q 0x8100 +#endif + +#ifndef ETH_P_8021AD +#define ETH_P_8021AD 0x88A8 +#endif + struct xdp_meta { __u64 rx_timestamp; __u64 xdp_timestamp;
Make VLAN c-tag and s-tag XDP hint testing more convenient by not skipping VLAN-ed packets. Allow both 802.1ad and 802.1Q headers. Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> --- tools/testing/selftests/bpf/progs/xdp_hw_metadata.c | 9 ++++++++- tools/testing/selftests/bpf/xdp_metadata.h | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)