Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327564
b: refs/heads/master
c: 4c6de2f
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Aug 20, 2012
1 parent f06cbac commit 57588a7
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 136 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: 62748b7bde84618f06b5c7a8733ae87776ec36c5
refs/heads/master: 4c6de2fedc321e17487b74547ad9f73f248faaac
15 changes: 15 additions & 0 deletions trunk/include/linux/packet_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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 @@ -27,6 +29,9 @@ struct packet_diag_msg {
enum {
PACKET_DIAG_INFO,
PACKET_DIAG_MCLIST,
PACKET_DIAG_RX_RING,
PACKET_DIAG_TX_RING,
PACKET_DIAG_FANOUT,

PACKET_DIAG_MAX,
};
Expand Down Expand Up @@ -54,4 +59,14 @@ struct packet_diag_mclist {
__u8 pdmc_addr[MAX_ADDR_LEN];
};

struct packet_diag_ring {
__u32 pdr_block_size;
__u32 pdr_block_nr;
__u32 pdr_frame_size;
__u32 pdr_frame_nr;
__u32 pdr_retire_tmo;
__u32 pdr_sizeof_priv;
__u32 pdr_features;
};

#endif
8 changes: 4 additions & 4 deletions trunk/include/linux/tipc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@

#define TIPC_CMD_GET_REMOTE_MNG 0x4003 /* tx none, rx unsigned */
#define TIPC_CMD_GET_MAX_PORTS 0x4004 /* tx none, rx unsigned */
#define TIPC_CMD_GET_MAX_PUBL 0x4005 /* tx none, rx unsigned */
#define TIPC_CMD_GET_MAX_SUBSCR 0x4006 /* tx none, rx unsigned */
#define TIPC_CMD_GET_MAX_PUBL 0x4005 /* obsoleted */
#define TIPC_CMD_GET_MAX_SUBSCR 0x4006 /* obsoleted */
#define TIPC_CMD_GET_MAX_ZONES 0x4007 /* obsoleted */
#define TIPC_CMD_GET_MAX_CLUSTERS 0x4008 /* obsoleted */
#define TIPC_CMD_GET_MAX_NODES 0x4009 /* obsoleted */
Expand All @@ -115,8 +115,8 @@
#define TIPC_CMD_SET_NODE_ADDR 0x8001 /* tx net_addr, rx none */
#define TIPC_CMD_SET_REMOTE_MNG 0x8003 /* tx unsigned, rx none */
#define TIPC_CMD_SET_MAX_PORTS 0x8004 /* tx unsigned, rx none */
#define TIPC_CMD_SET_MAX_PUBL 0x8005 /* tx unsigned, rx none */
#define TIPC_CMD_SET_MAX_SUBSCR 0x8006 /* tx unsigned, rx none */
#define TIPC_CMD_SET_MAX_PUBL 0x8005 /* obsoleted */
#define TIPC_CMD_SET_MAX_SUBSCR 0x8006 /* obsoleted */
#define TIPC_CMD_SET_MAX_ZONES 0x8007 /* obsoleted */
#define TIPC_CMD_SET_MAX_CLUSTERS 0x8008 /* obsoleted */
#define TIPC_CMD_SET_MAX_NODES 0x8009 /* obsoleted */
Expand Down
2 changes: 2 additions & 0 deletions trunk/net/ipv6/ip6_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,8 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
}
ip6_tnl_parm_from_user(&p1, &p);
t = ip6_tnl_locate(net, &p1, 0);
} else {
memset(&p, 0, sizeof(p));
}
if (t == NULL)
t = netdev_priv(dev);
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
68 changes: 67 additions & 1 deletion trunk/net/packet/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,70 @@ static int pdiag_put_mclist(const struct packet_sock *po, struct sk_buff *nlskb)
return 0;
}

static int pdiag_put_ring(struct packet_ring_buffer *ring, int ver, int nl_type,
struct sk_buff *nlskb)
{
struct packet_diag_ring pdr;

if (!ring->pg_vec || ((ver > TPACKET_V2) &&
(nl_type == PACKET_DIAG_TX_RING)))
return 0;

pdr.pdr_block_size = ring->pg_vec_pages << PAGE_SHIFT;
pdr.pdr_block_nr = ring->pg_vec_len;
pdr.pdr_frame_size = ring->frame_size;
pdr.pdr_frame_nr = ring->frame_max + 1;

if (ver > TPACKET_V2) {
pdr.pdr_retire_tmo = ring->prb_bdqc.retire_blk_tov;
pdr.pdr_sizeof_priv = ring->prb_bdqc.blk_sizeof_priv;
pdr.pdr_features = ring->prb_bdqc.feature_req_word;
} else {
pdr.pdr_retire_tmo = 0;
pdr.pdr_sizeof_priv = 0;
pdr.pdr_features = 0;
}

return nla_put(nlskb, nl_type, sizeof(pdr), &pdr);
}

static int pdiag_put_rings_cfg(struct packet_sock *po, struct sk_buff *skb)
{
int ret;

mutex_lock(&po->pg_vec_lock);
ret = pdiag_put_ring(&po->rx_ring, po->tp_version,
PACKET_DIAG_RX_RING, skb);
if (!ret)
ret = pdiag_put_ring(&po->tx_ring, po->tp_version,
PACKET_DIAG_TX_RING, skb);
mutex_unlock(&po->pg_vec_lock);

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)
{
struct nlmsghdr *nlh;
struct packet_diag_msg *rp;
const struct packet_sock *po = pkt_sk(sk);
struct packet_sock *po = pkt_sk(sk);

nlh = nlmsg_put(skb, pid, seq, SOCK_DIAG_BY_FAMILY, sizeof(*rp), flags);
if (!nlh)
Expand All @@ -93,6 +151,14 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag
pdiag_put_mclist(po, skb))
goto out_nlmsg_trim;

if ((req->pdiag_show & PACKET_SHOW_RING_CFG) &&
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
21 changes: 2 additions & 19 deletions trunk/net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ struct tipc_bearer tipc_bearers[MAX_BEARERS];

static void bearer_disable(struct tipc_bearer *b_ptr);

/**
* media_name_valid - validate media name
*
* Returns 1 if media name is valid, otherwise 0.
*/
static int media_name_valid(const char *name)
{
u32 len;

len = strlen(name);
if ((len + 1) > TIPC_MAX_MEDIA_NAME)
return 0;
return strspn(name, tipc_alphabet) == len;
}

/**
* tipc_media_find - locates specified media object by name
*/
Expand Down Expand Up @@ -102,7 +87,7 @@ int tipc_register_media(struct tipc_media *m_ptr)

write_lock_bh(&tipc_net_lock);

if (!media_name_valid(m_ptr->name))
if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME)
goto exit;
if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
!m_ptr->bcast_addr.broadcast)
Expand Down Expand Up @@ -206,9 +191,7 @@ static int bearer_name_validate(const char *name,

/* validate component parts of bearer name */
if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
(if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) ||
(strspn(media_name, tipc_alphabet) != (media_len - 1)) ||
(strspn(if_name, tipc_alphabet) != (if_len - 1)))
(if_len <= 1) || (if_len > TIPC_MAX_IF_NAME))
return 0;

/* return bearer name components, if necessary */
Expand Down
48 changes: 5 additions & 43 deletions trunk/net/tipc/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* net/tipc/config.c: TIPC configuration management code
*
* Copyright (c) 2002-2006, Ericsson AB
* Copyright (c) 2004-2007, 2010-2011, Wind River Systems
* Copyright (c) 2004-2007, 2010-2012, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -208,36 +208,6 @@ static struct sk_buff *cfg_set_remote_mng(void)
return tipc_cfg_reply_none();
}

static struct sk_buff *cfg_set_max_publications(void)
{
u32 value;

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value < 1 || value > 65535)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (max publications must be 1-65535)");
tipc_max_publications = value;
return tipc_cfg_reply_none();
}

static struct sk_buff *cfg_set_max_subscriptions(void)
{
u32 value;

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value < 1 || value > 65535)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (max subscriptions must be 1-65535");
tipc_max_subscriptions = value;
return tipc_cfg_reply_none();
}

static struct sk_buff *cfg_set_max_ports(void)
{
u32 value;
Expand Down Expand Up @@ -357,12 +327,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
case TIPC_CMD_SET_MAX_PORTS:
rep_tlv_buf = cfg_set_max_ports();
break;
case TIPC_CMD_SET_MAX_PUBL:
rep_tlv_buf = cfg_set_max_publications();
break;
case TIPC_CMD_SET_MAX_SUBSCR:
rep_tlv_buf = cfg_set_max_subscriptions();
break;
case TIPC_CMD_SET_NETID:
rep_tlv_buf = cfg_set_netid();
break;
Expand All @@ -372,12 +336,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
case TIPC_CMD_GET_MAX_PORTS:
rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_ports);
break;
case TIPC_CMD_GET_MAX_PUBL:
rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_publications);
break;
case TIPC_CMD_GET_MAX_SUBSCR:
rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_subscriptions);
break;
case TIPC_CMD_GET_NETID:
rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id);
break;
Expand All @@ -393,6 +351,10 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
case TIPC_CMD_GET_MAX_CLUSTERS:
case TIPC_CMD_SET_MAX_NODES:
case TIPC_CMD_GET_MAX_NODES:
case TIPC_CMD_SET_MAX_SUBSCR:
case TIPC_CMD_GET_MAX_SUBSCR:
case TIPC_CMD_SET_MAX_PUBL:
case TIPC_CMD_GET_MAX_PUBL:
case TIPC_CMD_SET_LOG_SIZE:
case TIPC_CMD_DUMP_LOG:
rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
Expand Down
22 changes: 7 additions & 15 deletions trunk/net/tipc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,13 @@


/* global variables used by multiple sub-systems within TIPC */
int tipc_random;

const char tipc_alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";
int tipc_random __read_mostly;

/* configurable TIPC parameters */
u32 tipc_own_addr;
int tipc_max_ports;
int tipc_max_subscriptions;
int tipc_max_publications;
int tipc_net_id;
int tipc_remote_management;
u32 tipc_own_addr __read_mostly;
int tipc_max_ports __read_mostly;
int tipc_net_id __read_mostly;
int tipc_remote_management __read_mostly;


/**
Expand Down Expand Up @@ -101,9 +96,8 @@ int tipc_core_start_net(unsigned long addr)
{
int res;

res = tipc_net_start(addr);
if (!res)
res = tipc_eth_media_start();
tipc_net_start(addr);
res = tipc_eth_media_start();
if (res)
tipc_core_stop_net();
return res;
Expand Down Expand Up @@ -160,8 +154,6 @@ static int __init tipc_init(void)

tipc_own_addr = 0;
tipc_remote_management = 1;
tipc_max_publications = 10000;
tipc_max_subscriptions = 2000;
tipc_max_ports = CONFIG_TIPC_PORTS;
tipc_net_id = 4711;

Expand Down
Loading

0 comments on commit 57588a7

Please sign in to comment.