@@ -126,6 +126,7 @@ enum bpf_map_type {
126
126
BPF_MAP_TYPE_XSKMAP ,
127
127
BPF_MAP_TYPE_SOCKHASH ,
128
128
BPF_MAP_TYPE_CGROUP_STORAGE ,
129
+ BPF_MAP_TYPE_REUSEPORT_SOCKARRAY ,
129
130
};
130
131
131
132
enum bpf_prog_type {
@@ -150,6 +151,7 @@ enum bpf_prog_type {
150
151
BPF_PROG_TYPE_CGROUP_SOCK_ADDR ,
151
152
BPF_PROG_TYPE_LWT_SEG6LOCAL ,
152
153
BPF_PROG_TYPE_LIRC_MODE2 ,
154
+ BPF_PROG_TYPE_SK_REUSEPORT ,
153
155
};
154
156
155
157
enum bpf_attach_type {
@@ -2113,6 +2115,14 @@ union bpf_attr {
2113
2115
* the shared data.
2114
2116
* Return
2115
2117
* Pointer to the local storage area.
2118
+ *
2119
+ * int bpf_sk_select_reuseport(struct sk_reuseport_md *reuse, struct bpf_map *map, void *key, u64 flags)
2120
+ * Description
2121
+ * Select a SO_REUSEPORT sk from a BPF_MAP_TYPE_REUSEPORT_ARRAY map
2122
+ * It checks the selected sk is matching the incoming
2123
+ * request in the skb.
2124
+ * Return
2125
+ * 0 on success, or a negative error in case of failure.
2116
2126
*/
2117
2127
#define __BPF_FUNC_MAPPER (FN ) \
2118
2128
FN(unspec), \
@@ -2196,7 +2206,8 @@ union bpf_attr {
2196
2206
FN(rc_keydown), \
2197
2207
FN(skb_cgroup_id), \
2198
2208
FN(get_current_cgroup_id), \
2199
- FN(get_local_storage),
2209
+ FN(get_local_storage), \
2210
+ FN(sk_select_reuseport),
2200
2211
2201
2212
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
2202
2213
* function eBPF program intends to call
@@ -2413,6 +2424,30 @@ struct sk_msg_md {
2413
2424
__u32 local_port ; /* stored in host byte order */
2414
2425
};
2415
2426
2427
+ struct sk_reuseport_md {
2428
+ /*
2429
+ * Start of directly accessible data. It begins from
2430
+ * the tcp/udp header.
2431
+ */
2432
+ void * data ;
2433
+ void * data_end ; /* End of directly accessible data */
2434
+ /*
2435
+ * Total length of packet (starting from the tcp/udp header).
2436
+ * Note that the directly accessible bytes (data_end - data)
2437
+ * could be less than this "len". Those bytes could be
2438
+ * indirectly read by a helper "bpf_skb_load_bytes()".
2439
+ */
2440
+ __u32 len ;
2441
+ /*
2442
+ * Eth protocol in the mac header (network byte order). e.g.
2443
+ * ETH_P_IP(0x0800) and ETH_P_IPV6(0x86DD)
2444
+ */
2445
+ __u32 eth_protocol ;
2446
+ __u32 ip_protocol ; /* IP protocol. e.g. IPPROTO_TCP, IPPROTO_UDP */
2447
+ __u32 bind_inany ; /* Is sock bound to an INANY address? */
2448
+ __u32 hash ; /* A hash of the packet 4 tuples */
2449
+ };
2450
+
2416
2451
#define BPF_TAG_SIZE 8
2417
2452
2418
2453
struct bpf_prog_info {
0 commit comments