Skip to content

Commit 04df41e

Browse files
Lawrence Brakmodavem330
authored andcommitted
bpf: update tools/include/uapi/linux/bpf.h
Update tools/include/uapi/linux/bpf.h to include changes related to new bpf sock_ops program type. Signed-off-by: Lawrence Brakmo <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6c4a01b commit 04df41e

File tree

1 file changed

+65
-1
lines changed
  • tools/include/uapi/linux

1 file changed

+65
-1
lines changed

tools/include/uapi/linux/bpf.h

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ enum bpf_prog_type {
120120
BPF_PROG_TYPE_LWT_IN,
121121
BPF_PROG_TYPE_LWT_OUT,
122122
BPF_PROG_TYPE_LWT_XMIT,
123+
BPF_PROG_TYPE_SOCK_OPS,
123124
};
124125

125126
enum bpf_attach_type {
126127
BPF_CGROUP_INET_INGRESS,
127128
BPF_CGROUP_INET_EGRESS,
128129
BPF_CGROUP_INET_SOCK_CREATE,
130+
BPF_CGROUP_SOCK_OPS,
129131
__MAX_BPF_ATTACH_TYPE
130132
};
131133

@@ -518,6 +520,17 @@ union bpf_attr {
518520
* Set full skb->hash.
519521
* @skb: pointer to skb
520522
* @hash: hash to set
523+
*
524+
* int bpf_setsockopt(bpf_socket, level, optname, optval, optlen)
525+
* Calls setsockopt. Not all opts are available, only those with
526+
* integer optvals plus TCP_CONGESTION.
527+
* Supported levels: SOL_SOCKET and IPROTO_TCP
528+
* @bpf_socket: pointer to bpf_socket
529+
* @level: SOL_SOCKET or IPROTO_TCP
530+
* @optname: option name
531+
* @optval: pointer to option value
532+
* @optlen: length of optval in byes
533+
* Return: 0 or negative error
521534
*/
522535
#define __BPF_FUNC_MAPPER(FN) \
523536
FN(unspec), \
@@ -568,7 +581,8 @@ union bpf_attr {
568581
FN(probe_read_str), \
569582
FN(get_socket_cookie), \
570583
FN(get_socket_uid), \
571-
FN(set_hash),
584+
FN(set_hash), \
585+
FN(setsockopt),
572586

573587
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
574588
* function eBPF program intends to call
@@ -720,4 +734,54 @@ struct bpf_map_info {
720734
__u32 map_flags;
721735
} __attribute__((aligned(8)));
722736

737+
/* User bpf_sock_ops struct to access socket values and specify request ops
738+
* and their replies.
739+
* New fields can only be added at the end of this structure
740+
*/
741+
struct bpf_sock_ops {
742+
__u32 op;
743+
union {
744+
__u32 reply;
745+
__u32 replylong[4];
746+
};
747+
__u32 family;
748+
__u32 remote_ip4;
749+
__u32 local_ip4;
750+
__u32 remote_ip6[4];
751+
__u32 local_ip6[4];
752+
__u32 remote_port;
753+
__u32 local_port;
754+
};
755+
756+
/* List of known BPF sock_ops operators.
757+
* New entries can only be added at the end
758+
*/
759+
enum {
760+
BPF_SOCK_OPS_VOID,
761+
BPF_SOCK_OPS_TIMEOUT_INIT, /* Should return SYN-RTO value to use or
762+
* -1 if default value should be used
763+
*/
764+
BPF_SOCK_OPS_RWND_INIT, /* Should return initial advertized
765+
* window (in packets) or -1 if default
766+
* value should be used
767+
*/
768+
BPF_SOCK_OPS_TCP_CONNECT_CB, /* Calls BPF program right before an
769+
* active connection is initialized
770+
*/
771+
BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB, /* Calls BPF program when an
772+
* active connection is
773+
* established
774+
*/
775+
BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, /* Calls BPF program when a
776+
* passive connection is
777+
* established
778+
*/
779+
BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control
780+
* needs ECN
781+
*/
782+
};
783+
784+
#define TCP_BPF_IW 1001 /* Set TCP initial congestion window */
785+
#define TCP_BPF_SNDCWND_CLAMP 1002 /* Set sndcwnd_clamp */
786+
723787
#endif /* _UAPI__LINUX_BPF_H__ */

0 commit comments

Comments
 (0)