@@ -120,12 +120,14 @@ enum bpf_prog_type {
120
120
BPF_PROG_TYPE_LWT_IN ,
121
121
BPF_PROG_TYPE_LWT_OUT ,
122
122
BPF_PROG_TYPE_LWT_XMIT ,
123
+ BPF_PROG_TYPE_SOCK_OPS ,
123
124
};
124
125
125
126
enum bpf_attach_type {
126
127
BPF_CGROUP_INET_INGRESS ,
127
128
BPF_CGROUP_INET_EGRESS ,
128
129
BPF_CGROUP_INET_SOCK_CREATE ,
130
+ BPF_CGROUP_SOCK_OPS ,
129
131
__MAX_BPF_ATTACH_TYPE
130
132
};
131
133
@@ -518,6 +520,17 @@ union bpf_attr {
518
520
* Set full skb->hash.
519
521
* @skb: pointer to skb
520
522
* @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
521
534
*/
522
535
#define __BPF_FUNC_MAPPER (FN ) \
523
536
FN(unspec), \
@@ -568,7 +581,8 @@ union bpf_attr {
568
581
FN(probe_read_str), \
569
582
FN(get_socket_cookie), \
570
583
FN(get_socket_uid), \
571
- FN(set_hash),
584
+ FN(set_hash), \
585
+ FN(setsockopt),
572
586
573
587
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
574
588
* function eBPF program intends to call
@@ -720,4 +734,54 @@ struct bpf_map_info {
720
734
__u32 map_flags ;
721
735
} __attribute__((aligned (8 )));
722
736
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
+
723
787
#endif /* _UAPI__LINUX_BPF_H__ */
0 commit comments