Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ip: expose inet sockopts through inet_diag

Expose all exisiting inet sockopt bits through inet_diag for debug purpose.
Corresponding changes in iproute2 ss will be submitted to output all
these values.

Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Wei Wang and committed by
David S. Miller
c1077616 a33d91ee

+37
+2
include/linux/inet_diag.h
··· 75 75 #ifdef CONFIG_SOCK_CGROUP_DATA 76 76 + nla_total_size_64bit(sizeof(u64)) /* INET_DIAG_CGROUP_ID */ 77 77 #endif 78 + + nla_total_size(sizeof(struct inet_diag_sockopt)) 79 + /* INET_DIAG_SOCKOPT */ 78 80 ; 79 81 } 80 82 int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
+18
include/uapi/linux/inet_diag.h
··· 160 160 INET_DIAG_ULP_INFO, 161 161 INET_DIAG_SK_BPF_STORAGES, 162 162 INET_DIAG_CGROUP_ID, 163 + INET_DIAG_SOCKOPT, 163 164 __INET_DIAG_MAX, 164 165 }; 165 166 ··· 182 181 __u32 idiag_wmem; 183 182 __u32 idiag_fmem; 184 183 __u32 idiag_tmem; 184 + }; 185 + 186 + /* INET_DIAG_SOCKOPT */ 187 + 188 + struct inet_diag_sockopt { 189 + __u8 recverr:1, 190 + is_icsk:1, 191 + freebind:1, 192 + hdrincl:1, 193 + mc_loop:1, 194 + transparent:1, 195 + mc_all:1, 196 + nodefrag:1; 197 + __u8 bind_address_no_port:1, 198 + recverr_rfc4884:1, 199 + defer_connect:1, 200 + unused:5; 185 201 }; 186 202 187 203 /* INET_DIAG_VEGASINFO */
+17
net/ipv4/inet_diag.c
··· 125 125 bool net_admin) 126 126 { 127 127 const struct inet_sock *inet = inet_sk(sk); 128 + struct inet_diag_sockopt inet_sockopt; 128 129 129 130 if (nla_put_u8(skb, INET_DIAG_SHUTDOWN, sk->sk_shutdown)) 130 131 goto errout; ··· 180 179 181 180 r->idiag_uid = from_kuid_munged(user_ns, sock_i_uid(sk)); 182 181 r->idiag_inode = sock_i_ino(sk); 182 + 183 + memset(&inet_sockopt, 0, sizeof(inet_sockopt)); 184 + inet_sockopt.recverr = inet->recverr; 185 + inet_sockopt.is_icsk = inet->is_icsk; 186 + inet_sockopt.freebind = inet->freebind; 187 + inet_sockopt.hdrincl = inet->hdrincl; 188 + inet_sockopt.mc_loop = inet->mc_loop; 189 + inet_sockopt.transparent = inet->transparent; 190 + inet_sockopt.mc_all = inet->mc_all; 191 + inet_sockopt.nodefrag = inet->nodefrag; 192 + inet_sockopt.bind_address_no_port = inet->bind_address_no_port; 193 + inet_sockopt.recverr_rfc4884 = inet->recverr_rfc4884; 194 + inet_sockopt.defer_connect = inet->defer_connect; 195 + if (nla_put(skb, INET_DIAG_SOCKOPT, sizeof(inet_sockopt), 196 + &inet_sockopt)) 197 + goto errout; 183 198 184 199 return 0; 185 200 errout: