Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327545
b: refs/heads/master
c: fff3321
h: refs/heads/master
i:
  327543: 6b46117
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Aug 20, 2012
1 parent d2c7c8b commit 718658c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 16f01365fa01150bf3606fe702a80a03ec87953a
refs/heads/master: fff3321d75b1a18231876a1aceb36eacbbf6221e
2 changes: 2 additions & 0 deletions trunk/include/linux/packet_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct packet_diag_req {
#define PACKET_SHOW_INFO 0x00000001 /* Basic packet_sk information */
#define PACKET_SHOW_MCLIST 0x00000002 /* A set of packet_diag_mclist-s */
#define PACKET_SHOW_RING_CFG 0x00000004 /* Rings configuration parameters */
#define PACKET_SHOW_FANOUT 0x00000008

struct packet_diag_msg {
__u8 pdiag_family;
Expand All @@ -30,6 +31,7 @@ enum {
PACKET_DIAG_MCLIST,
PACKET_DIAG_RX_RING,
PACKET_DIAG_TX_RING,
PACKET_DIAG_FANOUT,

PACKET_DIAG_MAX,
};
Expand Down
23 changes: 3 additions & 20 deletions trunk/net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,6 @@ static void prb_fill_vlan_info(struct tpacket_kbdq_core *,
struct tpacket3_hdr *);
static void packet_flush_mclist(struct sock *sk);

#define PACKET_FANOUT_MAX 256

struct packet_fanout {
#ifdef CONFIG_NET_NS
struct net *net;
#endif
unsigned int num_members;
u16 id;
u8 type;
u8 defrag;
atomic_t rr_cur;
struct list_head list;
struct sock *arr[PACKET_FANOUT_MAX];
spinlock_t lock;
atomic_t sk_ref;
struct packet_type prot_hook ____cacheline_aligned_in_smp;
};

struct packet_skb_cb {
unsigned int origlen;
union {
Expand Down Expand Up @@ -1148,7 +1130,8 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
return po->prot_hook.func(skb, dev, &po->prot_hook, orig_dev);
}

static DEFINE_MUTEX(fanout_mutex);
DEFINE_MUTEX(fanout_mutex);
EXPORT_SYMBOL_GPL(fanout_mutex);
static LIST_HEAD(fanout_list);

static void __fanout_link(struct sock *sk, struct packet_sock *po)
Expand Down Expand Up @@ -1260,9 +1243,9 @@ static void fanout_release(struct sock *sk)
if (!f)
return;

mutex_lock(&fanout_mutex);
po->fanout = NULL;

mutex_lock(&fanout_mutex);
if (atomic_dec_and_test(&f->sk_ref)) {
list_del(&f->list);
dev_remove_pack(&f->prot_hook);
Expand Down
20 changes: 20 additions & 0 deletions trunk/net/packet/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 19 additions & 1 deletion trunk/net/packet/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,25 @@ struct packet_ring_buffer {
atomic_t pending;
};

struct packet_fanout;
extern struct mutex fanout_mutex;
#define PACKET_FANOUT_MAX 256

struct packet_fanout {
#ifdef CONFIG_NET_NS
struct net *net;
#endif
unsigned int num_members;
u16 id;
u8 type;
u8 defrag;
atomic_t rr_cur;
struct list_head list;
struct sock *arr[PACKET_FANOUT_MAX];
spinlock_t lock;
atomic_t sk_ref;
struct packet_type prot_hook ____cacheline_aligned_in_smp;
};

struct packet_sock {
/* struct sock has to be the first member of packet_sock */
struct sock sk;
Expand Down

0 comments on commit 718658c

Please sign in to comment.