Message ID | 20230725035016.505386-1-rkannoth@marvell.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | David Ahern |
Headers | show |
Series | [iproute2-next] tc: Classifier support for SPI field | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
>From: Ratheesh Kannoth <rkannoth@marvell.com> > Sent: Tuesday, July 25, 2023 9:20 AM > To: dsahern@gmail.com; stephen@networkplumber.org > Cc: netdev@vger.kernel.org; Ratheesh Kannoth <rkannoth@marvell.com> > Subject: [PATCH iproute2-next] tc: Classifier support for SPI field > > tc flower support for SPI field in ESP and AH packets. > > Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com> > --- > include/uapi/linux/pkt_cls.h | 5 +++- > tc/f_flower.c | 55 ++++++++++++++++++++++++++++++++++-- > 2 files changed, 57 insertions(+), 3 deletions(-) > > diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index > 7865f5a9..fce639a6 100644 > --- a/include/uapi/linux/pkt_cls.h > +++ b/include/uapi/linux/pkt_cls.h > @@ -594,6 +594,9 @@ enum { > > TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */ > > + TCA_FLOWER_KEY_SPI, /* be32 */ > + TCA_FLOWER_KEY_SPI_MASK, /* be32 */ > + > TCA_FLOWER_L2_MISS, /* u8 */ > > TCA_FLOWER_KEY_CFM, /* nested */ As per https://lore.kernel.org/netdev/20230731120254.GB87829@unreal/T/#u , I will move these fields to end in the enum. Could you please discard https://patchwork.kernel.org/project/netdevbpf/patch/20230725035016.505386-1-rkannoth@marvell.com/ this from netdev patchwork ?
On 7/31/23 7:53 PM, Ratheesh Kannoth wrote: >> From: Ratheesh Kannoth <rkannoth@marvell.com> >> Sent: Tuesday, July 25, 2023 9:20 AM >> To: dsahern@gmail.com; stephen@networkplumber.org >> Cc: netdev@vger.kernel.org; Ratheesh Kannoth <rkannoth@marvell.com> >> Subject: [PATCH iproute2-next] tc: Classifier support for SPI field >> >> tc flower support for SPI field in ESP and AH packets. >> >> Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com> >> --- >> include/uapi/linux/pkt_cls.h | 5 +++- >> tc/f_flower.c | 55 ++++++++++++++++++++++++++++++++++-- >> 2 files changed, 57 insertions(+), 3 deletions(-) >> >> diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index >> 7865f5a9..fce639a6 100644 >> --- a/include/uapi/linux/pkt_cls.h >> +++ b/include/uapi/linux/pkt_cls.h >> @@ -594,6 +594,9 @@ enum { >> >> TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */ >> >> + TCA_FLOWER_KEY_SPI, /* be32 */ >> + TCA_FLOWER_KEY_SPI_MASK, /* be32 */ >> + >> TCA_FLOWER_L2_MISS, /* u8 */ >> >> TCA_FLOWER_KEY_CFM, /* nested */ > > As per https://lore.kernel.org/netdev/20230731120254.GB87829@unreal/T/#u , I will move these fields to end in the enum. > Could you please discard https://patchwork.kernel.org/project/netdevbpf/patch/20230725035016.505386-1-rkannoth@marvell.com/ this from netdev patchwork ? you do not need to include uapi changes in an iproute2 patch; headers are sync'ed from the kernel.
> From: David Ahern <dsahern@gmail.com> > Sent: Tuesday, August 1, 2023 8:06 AM > To: Ratheesh Kannoth <rkannoth@marvell.com>; > stephen@networkplumber.org > Cc: netdev@vger.kernel.org; davem@davemloft.net; kuba@kernel.org; > Leon Romanovsky <leon@kernel.org>; edumazet@google.com; > pabeni@redhat.com > Subject: [EXT] Re: [PATCH iproute2-next] tc: Classifier support for SPI field >> --- a/include/uapi/linux/pkt_cls.h > >> +++ b/include/uapi/linux/pkt_cls.h > >> @@ -594,6 +594,9 @@ enum { > >> > >> TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */ > >> > >> + TCA_FLOWER_KEY_SPI, /* be32 */ > >> + TCA_FLOWER_KEY_SPI_MASK, /* be32 */ > >> + > >> TCA_FLOWER_L2_MISS, /* u8 */ > >> > >> TCA_FLOWER_KEY_CFM, /* nested */ > > > > you do not need to include uapi changes in an iproute2 patch; headers are > sync'ed from the kernel. Thanks, but if user is compiling ip-route2 package in a different linux machine ? This is what I did. Not compiled against the kernel that I use. Backward compatibility will also break in this case, right ? correct me.
On 7/31/23 8:43 PM, Ratheesh Kannoth wrote: > Thanks, but if user is compiling ip-route2 package in a different linux machine ? > This is what I did. Not compiled against the kernel that I use. > Backward compatibility will also break in this case, right ? correct me. See `git log` on your git clone.
> From: David Ahern <dsahern@gmail.com> > Sent: Tuesday, August 1, 2023 8:16 AM > To: Ratheesh Kannoth <rkannoth@marvell.com>; > stephen@networkplumber.org > Cc: netdev@vger.kernel.org; davem@davemloft.net; kuba@kernel.org; > Leon Romanovsky <leon@kernel.org>; edumazet@google.com; > pabeni@redhat.com > Subject: [EXT] Re: [PATCH iproute2-next] tc: Classifier support for SPI field > See `git log` on your git clone. Got it. Thanks a lot !!
> From: Ratheesh Kannoth > Sent: Tuesday, August 1, 2023 8:20 AM > To: David Ahern <dsahern@gmail.com>; stephen@networkplumber.org > Cc: netdev@vger.kernel.org; davem@davemloft.net; kuba@kernel.org; > Leon Romanovsky <leon@kernel.org>; edumazet@google.com; > pabeni@redhat.com > Subject: RE: Re: [PATCH iproute2-next] tc: Classifier support for SPI field > Got it. Thanks a lot !! Linux kernel patches merged to net-next. Should I repush iproute2-next patch ? https://patchwork.kernel.org/project/netdevbpf/patch/20230725035016.505386-1-rkannoth@marvell.com/ I could not find the above patch in the live patches being tracked https://patchwork.kernel.org/project/netdevbpf/list/ -Ratheesh
On 8/2/23 3:30 AM, Ratheesh Kannoth wrote: >> From: Ratheesh Kannoth >> Sent: Tuesday, August 1, 2023 8:20 AM >> To: David Ahern <dsahern@gmail.com>; stephen@networkplumber.org >> Cc: netdev@vger.kernel.org; davem@davemloft.net; kuba@kernel.org; >> Leon Romanovsky <leon@kernel.org>; edumazet@google.com; >> pabeni@redhat.com >> Subject: RE: Re: [PATCH iproute2-next] tc: Classifier support for SPI field >> Got it. Thanks a lot !! > > Linux kernel patches merged to net-next. > Should I repush iproute2-next patch ? https://patchwork.kernel.org/project/netdevbpf/patch/20230725035016.505386-1-rkannoth@marvell.com/ > I could not find the above patch in the live patches being tracked https://patchwork.kernel.org/project/netdevbpf/list/ > > -Ratheesh I just merged header update. pull latest -next repo and update your patch
> From: David Ahern <dsahern@gmail.com> > Sent: Wednesday, August 2, 2023 9:01 PM > Subject: [EXT] Re: [PATCH iproute2-next] tc: Classifier support for SPI field > I just merged header update. pull latest -next repo and update your patch Done. Reposted the patch.
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 7865f5a9..fce639a6 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -594,6 +594,9 @@ enum { TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */ + TCA_FLOWER_KEY_SPI, /* be32 */ + TCA_FLOWER_KEY_SPI_MASK, /* be32 */ + TCA_FLOWER_L2_MISS, /* u8 */ TCA_FLOWER_KEY_CFM, /* nested */ diff --git a/tc/f_flower.c b/tc/f_flower.c index 6da5028a..d31a6fcb 100644 --- a/tc/f_flower.c +++ b/tc/f_flower.c @@ -60,7 +60,7 @@ static void explain(void) " ppp_proto [ ipv4 | ipv6 | mpls_uc | mpls_mc | PPP_PROTO ] |\n" " dst_mac MASKED-LLADDR |\n" " src_mac MASKED-LLADDR |\n" - " ip_proto [tcp | udp | sctp | icmp | icmpv6 | l2tp | IP-PROTO ] |\n" + " ip_proto [tcp | udp | sctp | icmp | icmpv6 | l2tp | esp | ah | IP-PROTO ] |\n" " ip_tos MASKED-IP_TOS |\n" " ip_ttl MASKED-IP_TTL |\n" " mpls LSE-LIST |\n" @@ -68,6 +68,7 @@ static void explain(void) " mpls_tc TC |\n" " mpls_bos BOS |\n" " mpls_ttl TTL |\n" + " spi SPI-INDEX |\n" " l2tpv3_sid LSID |\n" " dst_ip PREFIX |\n" " src_ip PREFIX |\n" @@ -437,6 +438,16 @@ static int flower_parse_ip_proto(char *str, __be16 eth_type, int type, eth_type != htons(ETH_P_IPV6)) goto err; ip_proto = IPPROTO_L2TP; + } else if (!strcmp(str, "esp")) { + if (eth_type != htons(ETH_P_IP) && + eth_type != htons(ETH_P_IPV6)) + goto err; + ip_proto = IPPROTO_ESP; + } else if (!strcmp(str, "ah")) { + if (eth_type != htons(ETH_P_IP) && + eth_type != htons(ETH_P_IPV6)) + goto err; + ip_proto = IPPROTO_AH; } else { ret = get_u8(&ip_proto, str, 16); if (ret) @@ -655,6 +666,29 @@ static int flower_parse_icmp(char *str, __u16 eth_type, __u8 ip_proto, return flower_parse_u8(str, value_type, mask_type, NULL, NULL, n); } +static int flower_parse_spi(char *str, __u8 ip_proto, struct nlmsghdr *n) +{ + __be32 spi; + int ret; + + if (ip_proto != IPPROTO_UDP && ip_proto != IPPROTO_ESP && ip_proto != IPPROTO_AH) { + fprintf(stderr, + "Can't set \"spi\" if ip_proto isn't ESP/UDP/AH\n"); + return -1; + } + + ret = get_be32(&spi, str, 16); + if (ret < 0) { + fprintf(stderr, "Illegal \"spi index\"\n"); + return -1; + } + + addattr32(n, MAX_MSG, TCA_FLOWER_KEY_SPI, spi); + addattr32(n, MAX_MSG, TCA_FLOWER_KEY_SPI_MASK, UINT32_MAX); + + return 0; +} + static int flower_parse_l2tpv3(char *str, __u8 ip_proto, struct nlmsghdr *n) { @@ -1935,6 +1969,11 @@ static int flower_parse_opt(struct filter_util *qu, char *handle, ret = flower_parse_l2tpv3(*argv, ip_proto, n); if (ret < 0) return -1; + } else if (!strcmp(*argv, "spi")) { + NEXT_ARG(); + ret = flower_parse_spi(*argv, ip_proto, n); + if (ret < 0) + return -1; } else if (matches(*argv, "arp_tip") == 0) { NEXT_ARG(); ret = flower_parse_arp_ip_addr(*argv, eth_type, @@ -2256,8 +2295,12 @@ static void flower_print_ip_proto(__u8 *p_ip_proto, sprintf(out, "icmpv6"); else if (ip_proto == IPPROTO_L2TP) sprintf(out, "l2tp"); + else if (ip_proto == IPPROTO_ESP) + sprintf(out, "esp"); + else if (ip_proto == IPPROTO_AH) + sprintf(out, "ah"); else - sprintf(out, "%02x", ip_proto); + sprintf(out, "0x%02x", ip_proto); print_nl(); print_string(PRINT_ANY, "ip_proto", " ip_proto %s", out); @@ -3024,6 +3067,14 @@ static int flower_print_opt(struct filter_util *qu, FILE *f, rta_getattr_be32(attr)); } + if (tb[TCA_FLOWER_KEY_SPI]) { + struct rtattr *attr = tb[TCA_FLOWER_KEY_SPI]; + + print_nl(); + print_hex(PRINT_ANY, "spi", " spi 0x%x", + rta_getattr_be32(attr)); + } + flower_print_ip4_addr("arp_sip", tb[TCA_FLOWER_KEY_ARP_SIP], tb[TCA_FLOWER_KEY_ARP_SIP_MASK]); flower_print_ip4_addr("arp_tip", tb[TCA_FLOWER_KEY_ARP_TIP],
tc flower support for SPI field in ESP and AH packets. Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com> --- include/uapi/linux/pkt_cls.h | 5 +++- tc/f_flower.c | 55 ++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-)