diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2012-08-16 05:36:48 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-20 02:23:14 -0700 |
commit | fff3321d75b1a18231876a1aceb36eacbbf6221e (patch) | |
tree | ff7d423fae980191ed922038ce5e1d0a05e19fab /net/packet/diag.c | |
parent | 16f01365fa01150bf3606fe702a80a03ec87953a (diff) | |
download | linux-fff3321d75b1a18231876a1aceb36eacbbf6221e.tar.gz linux-fff3321d75b1a18231876a1aceb36eacbbf6221e.tar.bz2 linux-fff3321d75b1a18231876a1aceb36eacbbf6221e.zip |
packet: Report fanout status via diag engine
Reported value is the same reported by the FANOUT getsockoption, but
unlike it, the absent fanout setup results in absent nlattr, rather
than in nlattr with zero value. This is done so, since zero fanout
report may mean both -- no fanout, and fanout with both id and type zero.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/diag.c')
-rw-r--r-- | net/packet/diag.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/net/packet/diag.c b/net/packet/diag.c index e3975e4d458c..bc33fbe8a5ef 100644 --- a/net/packet/diag.c +++ b/net/packet/diag.c @@ -109,6 +109,22 @@ static int pdiag_put_rings_cfg(struct packet_sock *po, struct sk_buff *skb) return ret; } +static int pdiag_put_fanout(struct packet_sock *po, struct sk_buff *nlskb) +{ + int ret = 0; + + mutex_lock(&fanout_mutex); + if (po->fanout) { + u32 val; + + val = (u32)po->fanout->id | ((u32)po->fanout->type << 16); + ret = nla_put_u32(nlskb, PACKET_DIAG_FANOUT, val); + } + mutex_unlock(&fanout_mutex); + + return ret; +} + static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag_req *req, u32 pid, u32 seq, u32 flags, int sk_ino) { @@ -139,6 +155,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag pdiag_put_rings_cfg(po, skb)) goto out_nlmsg_trim; + if ((req->pdiag_show & PACKET_SHOW_FANOUT) && + pdiag_put_fanout(po, skb)) + goto out_nlmsg_trim; + return nlmsg_end(skb, nlh); out_nlmsg_trim: |