[PATCH net-next 1/5] tcp: bpf: support bpf_getsockopt for TCP_BPF_RTO_MIN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Support bpf_getsockopt if application tries to know what the RTO MIN
of this socket is.

Signed-off-by: Jason Xing <kerneljasonxing@xxxxxxxxx>
---
 net/core/filter.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index a0867c5b32b3..31aef259e104 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5415,6 +5415,17 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
 		if (*optlen < 1)
 			return -EINVAL;
 		break;
+	case TCP_BPF_RTO_MIN:
+		if (*optlen != sizeof(int))
+			return -EINVAL;
+		if (getopt) {
+			int rto_min = inet_csk(sk)->icsk_rto_min;
+			int rto_min_us = jiffies_to_usecs(rto_min);
+
+			memcpy(optval, &rto_min_us, *optlen);
+			return 0;
+		}
+		return bpf_sol_tcp_setsockopt(sk, optname, optval, *optlen);
 	case TCP_BPF_SOCK_OPS_CB_FLAGS:
 		if (*optlen != sizeof(int))
 			return -EINVAL;
-- 
2.43.5





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux