net: Indicate whether a socket is a transparent socket

Modify the printout functions for IPv4-TCP, IPv4-UDP, IPv6-TCP, IPv6-UDP,
such that the state for the socket is printed as state = state | 0x80.
The actual socket state is unmodified. This change is required for the
user space to determine whether a socket is a transparent socket, and
to determine if the socket holder intends to consume packets locally
or to forward them to an external processor.

CRs-Fixed: 2156182
Change-Id: I2ca403b4c2c74e7ddcdbda53e4ba43613bae9c42
Signed-off-by: Sauvik Saha <ssaha@codeaurora.org>
This commit is contained in:
Sauvik Saha 2015-06-05 13:23:01 -06:00 • committed by Gerrit - the friendly Code Review server
commit b56ddcf9cd
4 changed files with 21 additions and 4 deletions

View file

@ -2433,6 +2433,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
__be32 src = inet->inet_rcv_saddr;
__u16 destp = ntohs(inet->inet_dport);
__u16 srcp = ntohs(inet->inet_sport);
__u8 seq_state = sk->sk_state;
int rx_queue;
int state;
@ -2453,6 +2454,9 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
}
state = inet_sk_state_load(sk);
if (inet->transparent)
seq_state |= 0x80;
if (state == TCP_LISTEN)
rx_queue = sk->sk_ack_backlog;
else
@ -2464,7 +2468,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
"%08X %5u %8d %lu %d %pK %lu %lu %u %u %d",
i, src, srcp, dest, destp, state,
i, src, srcp, dest, destp, seq_state,
READ_ONCE(tp->write_seq) - tp->snd_una,
rx_queue,
timer_active,

View file

@ -2902,10 +2902,14 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
__be32 src = inet->inet_rcv_saddr;
__u16 destp = ntohs(inet->inet_dport);
__u16 srcp = ntohs(inet->inet_sport);
__u8 state = sp->sk_state;
if (inet->transparent)
state |= 0x80;
seq_printf(f, "%5d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
bucket, src, srcp, dest, destp, sp->sk_state,
bucket, src, srcp, dest, destp, state,
sk_wmem_alloc_get(sp),
udp_rqueue_get(sp),
0, 0L, 0,

View file

@ -1027,9 +1027,14 @@ void __ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
__u16 srcp, __u16 destp, int rqueue, int bucket)
{
const struct in6_addr *dest, *src;
__u8 state = sp->sk_state;
dest = &sp->sk_v6_daddr;
src = &sp->sk_v6_rcv_saddr;
if (inet_sk(sp) && inet_sk(sp)->transparent)
state |= 0x80;
seq_printf(seq,
"%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
"%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
@ -1038,7 +1043,7 @@ void __ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
src->s6_addr32[2], src->s6_addr32[3], srcp,
dest->s6_addr32[0], dest->s6_addr32[1],
dest->s6_addr32[2], dest->s6_addr32[3], destp,
sp->sk_state,
state,
sk_wmem_alloc_get(sp),
rqueue,
0, 0L, 0,

View file

@ -1867,6 +1867,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
const struct fastopen_queue *fastopenq = &icsk->icsk_accept_queue.fastopenq;
int rx_queue;
int state;
__u8 state_seq = sp->sk_state;
dest = &sp->sk_v6_daddr;
src = &sp->sk_v6_rcv_saddr;
@ -1899,6 +1900,9 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
rx_queue = max_t(int, READ_ONCE(tp->rcv_nxt) -
READ_ONCE(tp->copied_seq), 0);
if (inet->transparent)
state_seq |= 0x80;
seq_printf(seq,
"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
"%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %lu %lu %u %u %d\n",
@ -1907,7 +1911,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
src->s6_addr32[2], src->s6_addr32[3], srcp,
dest->s6_addr32[0], dest->s6_addr32[1],
dest->s6_addr32[2], dest->s6_addr32[3], destp,
state,
state_seq,
READ_ONCE(tp->write_seq) - tp->snd_una,
rx_queue,
timer_active,