Skip to content

Commit f43875f

Browse files
matanb10Leon Romanovsky
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>
1 parent 6509d57 commit f43875f

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

drivers/infiniband/core/uverbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ struct ib_uverbs_flow_spec {
248248
};
249249
struct ib_uverbs_flow_spec_eth eth;
250250
struct ib_uverbs_flow_spec_ipv4 ipv4;
251+
struct ib_uverbs_flow_spec_esp esp;
251252
struct ib_uverbs_flow_spec_tcp_udp tcp_udp;
252253
struct ib_uverbs_flow_spec_ipv6 ipv6;
253254
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
@@ -2929,6 +2929,17 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
29292929
(ntohl(ib_spec->tunnel.val.tunnel_id)) >= BIT(24))
29302930
return -EINVAL;
29312931
break;
2932+
case IB_FLOW_SPEC_ESP:
2933+
ib_filter_sz = offsetof(struct ib_flow_esp_filter, real_sz);
2934+
actual_filter_sz = spec_filter_size(kern_spec_mask,
2935+
kern_filter_sz,
2936+
ib_filter_sz);
2937+
if (actual_filter_sz <= 0)
2938+
return -EINVAL;
2939+
ib_spec->esp.size = sizeof(struct ib_flow_spec_esp);
2940+
memcpy(&ib_spec->esp.val, kern_spec_val, actual_filter_sz);
2941+
memcpy(&ib_spec->esp.mask, kern_spec_mask, actual_filter_sz);
2942+
break;
29322943
default:
29332944
return -EINVAL;
29342945
}

include/rdma/ib_verbs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,7 @@ enum ib_flow_spec_type {
18161816
/* L3 header*/
18171817
IB_FLOW_SPEC_IPV4 = 0x30,
18181818
IB_FLOW_SPEC_IPV6 = 0x31,
1819+
IB_FLOW_SPEC_ESP = 0x34,
18191820
/* L4 headers*/
18201821
IB_FLOW_SPEC_TCP = 0x40,
18211822
IB_FLOW_SPEC_UDP = 0x41,
@@ -1948,6 +1949,20 @@ struct ib_flow_spec_tunnel {
19481949
struct ib_flow_tunnel_filter mask;
19491950
};
19501951

1952+
struct ib_flow_esp_filter {
1953+
__be32 spi;
1954+
__be32 seq;
1955+
/* Must be last */
1956+
u8 real_sz[0];
1957+
};
1958+
1959+
struct ib_flow_spec_esp {
1960+
u32 type;
1961+
u16 size;
1962+
struct ib_flow_esp_filter val;
1963+
struct ib_flow_esp_filter mask;
1964+
};
1965+
19511966
struct ib_flow_spec_action_tag {
19521967
enum ib_flow_spec_type type;
19531968
u16 size;
@@ -1976,6 +1991,7 @@ union ib_flow_spec {
19761991
struct ib_flow_spec_tcp_udp tcp_udp;
19771992
struct ib_flow_spec_ipv6 ipv6;
19781993
struct ib_flow_spec_tunnel tunnel;
1994+
struct ib_flow_spec_esp esp;
19791995
struct ib_flow_spec_action_tag flow_tag;
19801996
struct ib_flow_spec_action_drop drop;
19811997
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)