Skip to content

Commit 56ab0b3

Browse files
matanb10jgunthorpe
authored andcommitted
IB/uverbs: Introduce ESP steering match filter
Adding a new ESP steering match filter that could match against spi and seq used in IPSec protocol. Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 7d12f8d commit 56ab0b3

4 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎drivers/infiniband/core/uverbs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ struct ib_uverbs_flow_spec {
257257
};
258258
struct ib_uverbs_flow_spec_eth eth;
259259
struct ib_uverbs_flow_spec_ipv4 ipv4;
260+
struct ib_uverbs_flow_spec_esp esp;
260261
struct ib_uverbs_flow_spec_tcp_udp tcp_udp;
261262
struct ib_uverbs_flow_spec_ipv6 ipv6;
262263
struct ib_uverbs_flow_spec_action_tag flow_tag;

‎drivers/infiniband/core/uverbs_cmd.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,17 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
29312931
(ntohl(ib_spec->tunnel.val.tunnel_id)) >= BIT(24))
29322932
return -EINVAL;
29332933
break;
2934+
case IB_FLOW_SPEC_ESP:
2935+
ib_filter_sz = offsetof(struct ib_flow_esp_filter, real_sz);
2936+
actual_filter_sz = spec_filter_size(kern_spec_mask,
2937+
kern_filter_sz,
2938+
ib_filter_sz);
2939+
if (actual_filter_sz <= 0)
2940+
return -EINVAL;
2941+
ib_spec->esp.size = sizeof(struct ib_flow_spec_esp);
2942+
memcpy(&ib_spec->esp.val, kern_spec_val, actual_filter_sz);
2943+
memcpy(&ib_spec->esp.mask, kern_spec_mask, actual_filter_sz);
2944+
break;
29342945
default:
29352946
return -EINVAL;
29362947
}

‎include/rdma/ib_verbs.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,7 @@ enum ib_flow_spec_type {
18281828
/* L3 header*/
18291829
IB_FLOW_SPEC_IPV4 = 0x30,
18301830
IB_FLOW_SPEC_IPV6 = 0x31,
1831+
IB_FLOW_SPEC_ESP = 0x34,
18311832
/* L4 headers*/
18321833
IB_FLOW_SPEC_TCP = 0x40,
18331834
IB_FLOW_SPEC_UDP = 0x41,
@@ -1960,6 +1961,20 @@ struct ib_flow_spec_tunnel {
19601961
struct ib_flow_tunnel_filter mask;
19611962
};
19621963

1964+
struct ib_flow_esp_filter {
1965+
__be32 spi;
1966+
__be32 seq;
1967+
/* Must be last */
1968+
u8 real_sz[0];
1969+
};
1970+
1971+
struct ib_flow_spec_esp {
1972+
u32 type;
1973+
u16 size;
1974+
struct ib_flow_esp_filter val;
1975+
struct ib_flow_esp_filter mask;
1976+
};
1977+
19631978
struct ib_flow_spec_action_tag {
19641979
enum ib_flow_spec_type type;
19651980
u16 size;
@@ -1988,6 +2003,7 @@ union ib_flow_spec {
19882003
struct ib_flow_spec_tcp_udp tcp_udp;
19892004
struct ib_flow_spec_ipv6 ipv6;
19902005
struct ib_flow_spec_tunnel tunnel;
2006+
struct ib_flow_spec_esp esp;
19912007
struct ib_flow_spec_action_tag flow_tag;
19922008
struct ib_flow_spec_action_drop drop;
19932009
struct ib_flow_spec_action_handle action;

‎include/uapi/rdma/ib_user_verbs.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,24 @@ struct ib_uverbs_flow_spec_tunnel {
10141014
struct ib_uverbs_flow_tunnel_filter mask;
10151015
};
10161016

1017+
struct ib_uverbs_flow_spec_esp_filter {
1018+
__u32 spi;
1019+
__u32 seq;
1020+
};
1021+
1022+
struct ib_uverbs_flow_spec_esp {
1023+
union {
1024+
struct ib_uverbs_flow_spec_hdr hdr;
1025+
struct {
1026+
__u32 type;
1027+
__u16 size;
1028+
__u16 reserved;
1029+
};
1030+
};
1031+
struct ib_uverbs_flow_spec_esp_filter val;
1032+
struct ib_uverbs_flow_spec_esp_filter mask;
1033+
};
1034+
10171035
struct ib_uverbs_flow_attr {
10181036
__u32 type;
10191037
__u16 size;

0 commit comments

Comments
 (0)