diff --git a/man/man8/tc-flower.8 b/man/man8/tc-flower.8
index 3f8ba4656ef4..88881671c693 100644
--- a/man/man8/tc-flower.8
+++ b/man/man8/tc-flower.8
@@ -56,6 +56,12 @@ flower \- flow based traffic control filter
.IR TTL " | "
.B l2tpv3_sid
.IR LSID " | "
+.B psp_spi
+.IR SPI "[/" MASK "] | "
+.B psp_ver
+.IR VERSION " | "
+.B psp_dev
+.IR PSP_DEV_ID " | "
.BR ip_proto " { " tcp " | " udp " | " sctp " | " icmp " | " icmpv6 " | " l2tp " | "
.IR IP_PROTO " } | "
.B ip_tos@@ -323,6 +329,29 @@ Match on L2TPv3 session id field transported over IPv4 or IPv6.
.I LSID
is an unsigned 32 bit value in decimal format.
.TP
+.BI psp_spi " SPI[/MASK]"
+Match on the SPI which a PSP device decrypted the packet with.
+.I SPI
+and
+.I MASK
+are unsigned 32 bit values in hexadecimal format.
+.TP
+.BI psp_ver " VERSION"
+Match on the PSP version which the packet was decrypted with, as numbered
+by the PSP netlink family (0 for hdr0-aes-gcm-128, 1 for hdr0-aes-gcm-256,
+2 for hdr0-aes-gmac-128, 3 for hdr0-aes-gmac-256).
+.TP
+.BI psp_dev " PSP_DEV_ID"
+Match on the ID of the PSP device which decrypted the packet, from the PSP
+netlink family.
+.IP
+The PSP keys only ever match packets which a PSP device decrypted, even with
+a zero mask:
+.B psp_spi 0/0
+matches any packet decrypted with PSP. See
+.BR tc-psp (8)
+for an example.
+.TP
.BI ip_proto " IP_PROTO"
Match on layer four protocol.
.I IP_PROTO
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 6fc2c6a1ccc6..6539856ba9d5 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -73,6 +73,9 @@ static void explain(void)
" mpls_bos BOS |\n"
" mpls_ttl TTL |\n"
" spi SPI-INDEX |\n"
+ " psp_spi SPI[/MASK] |\n"
+ " psp_ver VERSION |\n"
+ " psp_dev PSP-DEV-ID |\n"
" l2tpv3_sid LSID |\n"
" dst_ip PREFIX |\n"
" src_ip PREFIX |\n"
@@ -678,6 +681,25 @@ 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_psp_spi(char *str, struct nlmsghdr *n)
+{
+ __u32 spi, mask = UINT32_MAX;
+ char *slash;
+
+ slash = strchr(str, '/');
+ if (slash) {
+ *slash = '\0';
+ if (get_u32(&mask, slash + 1, 16))
+ return -1;
+ }
+ if (get_u32(&spi, str, 16))
+ return -1;
+
+ addattr32(n, MAX_MSG, TCA_FLOWER_KEY_PSP_SPI, htonl(spi));
+ addattr32(n, MAX_MSG, TCA_FLOWER_KEY_PSP_SPI_MASK, htonl(mask));
+ return 0;
+}
+
static int flower_parse_spi(char *str, __u8 ip_proto, struct nlmsghdr *n)
{
__be32 spi;@@ -2074,6 +2096,31 @@ static int flower_parse_opt(const struct filter_util *qu, char *handle,
ret = flower_parse_l2tpv3(*argv, ip_proto, n);
if (ret < 0)
return -1;
+ } else if (!strcmp(*argv, "psp_spi")) {
+ NEXT_ARG();
+ ret = flower_parse_psp_spi(*argv, n);
+ if (ret < 0) {
+ fprintf(stderr, "Illegal \"psp_spi\"\n");
+ return -1;
+ }
+ } else if (!strcmp(*argv, "psp_ver")) {
+ __u8 ver;
+
+ NEXT_ARG();
+ if (get_u8(&ver, *argv, 10)) {
+ fprintf(stderr, "Illegal \"psp_ver\"\n");
+ return -1;
+ }
+ addattr8(n, MAX_MSG, TCA_FLOWER_KEY_PSP_VERSION, ver);
+ } else if (!strcmp(*argv, "psp_dev")) {
+ __u32 dev;
+
+ NEXT_ARG();
+ if (get_u32(&dev, *argv, 10)) {
+ fprintf(stderr, "Illegal \"psp_dev\"\n");
+ return -1;
+ }
+ addattr32(n, MAX_MSG, TCA_FLOWER_KEY_PSP_DEV, dev);
} else if (!strcmp(*argv, "spi")) {
NEXT_ARG();
ret = flower_parse_spi(*argv, ip_proto, n);@@ -3236,6 +3283,30 @@ static int flower_print_opt(const struct filter_util *qu, FILE *f,
rta_getattr_be32(attr));
}
+ if (tb[TCA_FLOWER_KEY_PSP_SPI]) {
+ __u32 mask = UINT32_MAX;
+
+ if (tb[TCA_FLOWER_KEY_PSP_SPI_MASK])
+ mask = rta_getattr_be32(tb[TCA_FLOWER_KEY_PSP_SPI_MASK]);
+ print_nl();
+ print_hex(PRINT_ANY, "psp_spi", " psp_spi 0x%x",
+ rta_getattr_be32(tb[TCA_FLOWER_KEY_PSP_SPI]));
+ if (mask != UINT32_MAX)
+ print_hex(PRINT_ANY, "psp_spi_mask", "/0x%x", mask);
+ }
+
+ if (tb[TCA_FLOWER_KEY_PSP_VERSION]) {
+ print_nl();
+ print_uint(PRINT_ANY, "psp_ver", " psp_ver %u",
+ rta_getattr_u8(tb[TCA_FLOWER_KEY_PSP_VERSION]));
+ }
+
+ if (tb[TCA_FLOWER_KEY_PSP_DEV]) {
+ print_nl();
+ print_uint(PRINT_ANY, "psp_dev", " psp_dev %u",
+ rta_getattr_u32(tb[TCA_FLOWER_KEY_PSP_DEV]));
+ }
+
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],--
2.53.0-Meta