* [PATCH net-next-2.6 3/3] bridge: use rx_handler_data pointer to store net_bridge_port pointer
From: Jiri Pirko @ 2010-06-10 13:36 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, eric.dumazet
In-Reply-To: <20100610133412.GC2618@psychotron.lab.eng.brq.redhat.com>
Register net_bridge_port pointer as rx_handler data pointer. As br_port is
removed from struct net_device, another netdev priv_flag is added to indicate
the device serves as a bridge port. Also rcuized pointers are now correctly
dereferenced in br_fdb.c and in netfilter parts.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/ksz884x.c | 2 +-
drivers/staging/batman-adv/hard-interface.c | 2 +-
include/linux/if.h | 1 +
include/linux/netdevice.h | 2 --
net/bridge/br_fdb.c | 4 ++--
net/bridge/br_if.c | 23 +++++++++++++----------
net/bridge/br_input.c | 9 ++++-----
net/bridge/br_netfilter.c | 11 ++++++-----
net/bridge/br_netlink.c | 9 +++++----
net/bridge/br_notify.c | 5 +++--
net/bridge/br_private.h | 4 ++++
net/bridge/br_stp_bpdu.c | 5 +++--
net/bridge/netfilter/ebt_redirect.c | 3 ++-
net/bridge/netfilter/ebt_ulog.c | 8 +++++---
net/bridge/netfilter/ebtables.c | 11 +++++++----
net/core/dev.c | 3 ++-
net/netfilter/nfnetlink_log.c | 6 ++++--
net/netfilter/nfnetlink_queue.c | 6 ++++--
net/wireless/nl80211.c | 2 +-
net/wireless/util.c | 4 ++--
20 files changed, 70 insertions(+), 50 deletions(-)
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index 7805bbf..b0c876d 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -5718,7 +5718,7 @@ static void dev_set_promiscuous(struct net_device *dev, struct dev_priv *priv,
* from the bridge.
*/
if ((hw->features & STP_SUPPORT) && !promiscuous &&
- dev->br_port) {
+ dev->priv_flags & IFF_BRIDGE_PORT) {
struct ksz_switch *sw = hw->ksz_switch;
int port = priv->port.first_port;
diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c
index 7a582e8..5ede9c2 100644
--- a/drivers/staging/batman-adv/hard-interface.c
+++ b/drivers/staging/batman-adv/hard-interface.c
@@ -71,7 +71,7 @@ static int is_valid_iface(struct net_device *net_dev)
#endif
/* Device is being bridged */
- /* if (net_dev->br_port != NULL)
+ /* if (net_dev->priv_flags & IFF_BRIDGE_PORT)
return 0; */
return 1;
diff --git a/include/linux/if.h b/include/linux/if.h
index 31f2e27..53558ec 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -74,6 +74,7 @@
#define IFF_IN_NETPOLL 0x1000 /* whether we are processing netpoll */
#define IFF_DISABLE_NETPOLL 0x2000 /* disable netpoll at run-time */
#define IFF_MACVLAN_PORT 0x4000 /* device used as macvlan port */
+#define IFF_BRIDGE_PORT 0x8000 /* device used as bridge port */
#define IF_GET_IFACE 0x0001 /* for querying only */
#define IF_GET_PROTO 0x0002
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 37faf51..f4e1f75 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1028,8 +1028,6 @@ struct net_device {
/* mid-layer private */
void *ml_priv;
- /* bridge stuff */
- struct net_bridge_port *br_port;
/* GARP */
struct garp_port *garp_port;
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 2663743..6818e60 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -242,11 +242,11 @@ int br_fdb_test_addr(struct net_device *dev, unsigned char *addr)
struct net_bridge_fdb_entry *fdb;
int ret;
- if (!dev->br_port)
+ if (!br_port_exists(dev))
return 0;
rcu_read_lock();
- fdb = __br_fdb_get(dev->br_port->br, addr);
+ fdb = __br_fdb_get(br_port_get_rcu(dev)->br, addr);
ret = fdb && fdb->dst->dev != dev &&
fdb->dst->state == BR_STATE_FORWARDING;
rcu_read_unlock();
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 90ac003..099495e 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -147,8 +147,9 @@ static void del_nbp(struct net_bridge_port *p)
list_del_rcu(&p->list);
+ dev->priv_flags &= ~IFF_BRIDGE_PORT;
+
netdev_rx_handler_unregister(dev);
- rcu_assign_pointer(dev->br_port, NULL);
br_multicast_del_port(p);
@@ -401,7 +402,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
return -ELOOP;
/* Device is already being bridged */
- if (dev->br_port != NULL)
+ if (br_port_exists(dev))
return -EBUSY;
/* No bridging devices that dislike that (e.g. wireless) */
@@ -429,11 +430,11 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (err)
goto err2;
- rcu_assign_pointer(dev->br_port, p);
-
- err = netdev_rx_handler_register(dev, br_handle_frame, NULL);
+ err = netdev_rx_handler_register(dev, br_handle_frame, p);
if (err)
- goto err3;
+ goto err2;
+
+ dev->priv_flags |= IFF_BRIDGE_PORT;
dev_disable_lro(dev);
@@ -457,8 +458,6 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
br_netpoll_enable(br, dev);
return 0;
-err3:
- rcu_assign_pointer(dev->br_port, NULL);
err2:
br_fdb_delete_by_port(br, p, 1);
err1:
@@ -475,9 +474,13 @@ put_back:
/* called with RTNL */
int br_del_if(struct net_bridge *br, struct net_device *dev)
{
- struct net_bridge_port *p = dev->br_port;
+ struct net_bridge_port *p;
+
+ if (!br_port_exists(dev))
+ return -EINVAL;
- if (!p || p->br != br)
+ p = br_port_get(dev);
+ if (p->br != br)
return -EINVAL;
del_nbp(p);
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 99647d8..f076c9d 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -41,7 +41,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
int br_handle_frame_finish(struct sk_buff *skb)
{
const unsigned char *dest = eth_hdr(skb)->h_dest;
- struct net_bridge_port *p = rcu_dereference(skb->dev->br_port);
+ struct net_bridge_port *p = br_port_get_rcu(skb->dev);
struct net_bridge *br;
struct net_bridge_fdb_entry *dst;
struct net_bridge_mdb_entry *mdst;
@@ -111,10 +111,9 @@ drop:
/* note: already called with rcu_read_lock (preempt_disabled) */
static int br_handle_local_finish(struct sk_buff *skb)
{
- struct net_bridge_port *p = rcu_dereference(skb->dev->br_port);
+ struct net_bridge_port *p = br_port_get_rcu(skb->dev);
- if (p)
- br_fdb_update(p->br, p, eth_hdr(skb)->h_source);
+ br_fdb_update(p->br, p, eth_hdr(skb)->h_source);
return 0; /* process further */
}
@@ -151,7 +150,7 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb)
if (!skb)
return NULL;
- p = rcu_dereference(skb->dev->br_port);
+ p = br_port_get_rcu(skb->dev);
if (unlikely(is_link_local(dest))) {
/* Pause frames shouldn't be passed up by driver anyway */
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 4442099..7d7af6e 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -127,16 +127,17 @@ void br_netfilter_rtable_init(struct net_bridge *br)
static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
{
- struct net_bridge_port *port = rcu_dereference(dev->br_port);
-
- return port ? &port->br->fake_rtable : NULL;
+ if (!br_port_exists(dev))
+ return NULL;
+ return &br_port_get_rcu(dev)->br->fake_rtable;
}
static inline struct net_device *bridge_parent(const struct net_device *dev)
{
- struct net_bridge_port *port = rcu_dereference(dev->br_port);
+ if (!br_port_exists(dev))
+ return NULL;
- return port ? port->br->dev : NULL;
+ return br_port_get_rcu(dev)->br->dev;
}
static inline struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index fe0a790..4a6a378 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -120,10 +120,11 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
idx = 0;
for_each_netdev(net, dev) {
/* not a bridge port */
- if (dev->br_port == NULL || idx < cb->args[0])
+ if (!br_port_exists(dev) || idx < cb->args[0])
goto skip;
- if (br_fill_ifinfo(skb, dev->br_port, NETLINK_CB(cb->skb).pid,
+ if (br_fill_ifinfo(skb, br_port_get(dev),
+ NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq, RTM_NEWLINK,
NLM_F_MULTI) < 0)
break;
@@ -168,9 +169,9 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
if (!dev)
return -ENODEV;
- p = dev->br_port;
- if (!p)
+ if (!br_port_exists(dev))
return -EINVAL;
+ p = br_port_get(dev);
/* if kernel STP is running, don't allow changes */
if (p->br->stp_enabled == BR_KERNEL_STP)
diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c
index 717e1fd..404d4e1 100644
--- a/net/bridge/br_notify.c
+++ b/net/bridge/br_notify.c
@@ -32,14 +32,15 @@ struct notifier_block br_device_notifier = {
static int br_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
- struct net_bridge_port *p = dev->br_port;
+ struct net_bridge_port *p = br_port_get(dev);
struct net_bridge *br;
int err;
/* not a port of a bridge */
- if (p == NULL)
+ if (!br_port_exists(dev))
return NOTIFY_DONE;
+ p = br_port_get(dev);
br = p->br;
switch (event) {
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index c83519b..94f41b7 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -145,6 +145,10 @@ struct net_bridge_port
#endif
};
+#define br_port_get_rcu(dev) ((struct net_bridge_port *) rcu_dereference(dev->rx_handler_data))
+#define br_port_get(dev) ((struct net_bridge_port *) dev->rx_handler_data)
+#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
+
struct br_cpu_netstats {
unsigned long rx_packets;
unsigned long rx_bytes;
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 217bd22..70aecb4 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -137,12 +137,13 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
struct net_device *dev)
{
const unsigned char *dest = eth_hdr(skb)->h_dest;
- struct net_bridge_port *p = rcu_dereference(dev->br_port);
+ struct net_bridge_port *p;
struct net_bridge *br;
const unsigned char *buf;
- if (!p)
+ if (!br_port_exists(dev))
goto err;
+ p = br_port_get_rcu(dev);
if (!pskb_may_pull(skb, 4))
goto err;
diff --git a/net/bridge/netfilter/ebt_redirect.c b/net/bridge/netfilter/ebt_redirect.c
index 9e19166..46624bb 100644
--- a/net/bridge/netfilter/ebt_redirect.c
+++ b/net/bridge/netfilter/ebt_redirect.c
@@ -24,8 +24,9 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
return EBT_DROP;
if (par->hooknum != NF_BR_BROUTING)
+ /* rcu_read_lock()ed by nf_hook_slow */
memcpy(eth_hdr(skb)->h_dest,
- par->in->br_port->br->dev->dev_addr, ETH_ALEN);
+ br_port_get_rcu(par->in)->br->dev->dev_addr, ETH_ALEN);
else
memcpy(eth_hdr(skb)->h_dest, par->in->dev_addr, ETH_ALEN);
skb->pkt_type = PACKET_HOST;
diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index ae3c7ce..26377e9 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -177,8 +177,9 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,
if (in) {
strcpy(pm->physindev, in->name);
/* If in isn't a bridge, then physindev==indev */
- if (in->br_port)
- strcpy(pm->indev, in->br_port->br->dev->name);
+ if (br_port_exists(in))
+ /* rcu_read_lock()ed by nf_hook_slow */
+ strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
else
strcpy(pm->indev, in->name);
} else
@@ -187,7 +188,8 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,
if (out) {
/* If out exists, then out is a bridge port */
strcpy(pm->physoutdev, out->name);
- strcpy(pm->outdev, out->br_port->br->dev->name);
+ /* rcu_read_lock()ed by nf_hook_slow */
+ strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
} else
pm->outdev[0] = pm->physoutdev[0] = '\0';
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 59ca00e..bcc102e 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -140,11 +140,14 @@ ebt_basic_match(const struct ebt_entry *e, const struct ethhdr *h,
return 1;
if (FWINV2(ebt_dev_check(e->out, out), EBT_IOUT))
return 1;
- if ((!in || !in->br_port) ? 0 : FWINV2(ebt_dev_check(
- e->logical_in, in->br_port->br->dev), EBT_ILOGICALIN))
+ /* rcu_read_lock()ed by nf_hook_slow */
+ if (in && br_port_exists(in) &&
+ FWINV2(ebt_dev_check(e->logical_in, br_port_get_rcu(in)->br->dev),
+ EBT_ILOGICALIN))
return 1;
- if ((!out || !out->br_port) ? 0 : FWINV2(ebt_dev_check(
- e->logical_out, out->br_port->br->dev), EBT_ILOGICALOUT))
+ if (out && br_port_exists(out) &&
+ FWINV2(ebt_dev_check(e->logical_out, br_port_get_rcu(out)->br->dev),
+ EBT_ILOGICALOUT))
return 1;
if (e->bitmask & EBT_SOURCEMAC) {
diff --git a/net/core/dev.c b/net/core/dev.c
index c49dda0..cf95489 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2767,7 +2767,8 @@ int __skb_bond_should_drop(struct sk_buff *skb, struct net_device *master)
if (master->priv_flags & IFF_MASTER_ARPMON)
dev->last_rx = jiffies;
- if ((master->priv_flags & IFF_MASTER_ALB) && master->br_port) {
+ if ((master->priv_flags & IFF_MASTER_ALB) &&
+ (master->priv_flags & IFF_BRIDGE_PORT)) {
/* Do address unmangle. The local destination address
* will be always the one master has. Provides the right
* functionality in a bridge.
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index fc9a211..e0504e9 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -403,8 +403,9 @@ __build_packet_message(struct nfulnl_instance *inst,
NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_PHYSINDEV,
htonl(indev->ifindex));
/* this is the bridge group "brX" */
+ /* rcu_read_lock()ed by nf_hook_slow or nf_log_packet */
NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_INDEV,
- htonl(indev->br_port->br->dev->ifindex));
+ htonl(br_port_get_rcu(indev)->br->dev->ifindex));
} else {
/* Case 2: indev is bridge group, we need to look for
* physical device (when called from ipv4) */
@@ -430,8 +431,9 @@ __build_packet_message(struct nfulnl_instance *inst,
NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_PHYSOUTDEV,
htonl(outdev->ifindex));
/* this is the bridge group "brX" */
+ /* rcu_read_lock()ed by nf_hook_slow or nf_log_packet */
NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_OUTDEV,
- htonl(outdev->br_port->br->dev->ifindex));
+ htonl(br_port_get_rcu(outdev)->br->dev->ifindex));
} else {
/* Case 2: indev is a bridge group, we need to look
* for physical device (when called from ipv4) */
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 12e1ab3..cc3ae86 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -296,8 +296,9 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
NLA_PUT_BE32(skb, NFQA_IFINDEX_PHYSINDEV,
htonl(indev->ifindex));
/* this is the bridge group "brX" */
+ /* rcu_read_lock()ed by __nf_queue */
NLA_PUT_BE32(skb, NFQA_IFINDEX_INDEV,
- htonl(indev->br_port->br->dev->ifindex));
+ htonl(br_port_get_rcu(indev)->br->dev->ifindex));
} else {
/* Case 2: indev is bridge group, we need to look for
* physical device (when called from ipv4) */
@@ -321,8 +322,9 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
NLA_PUT_BE32(skb, NFQA_IFINDEX_PHYSOUTDEV,
htonl(outdev->ifindex));
/* this is the bridge group "brX" */
+ /* rcu_read_lock()ed by __nf_queue */
NLA_PUT_BE32(skb, NFQA_IFINDEX_OUTDEV,
- htonl(outdev->br_port->br->dev->ifindex));
+ htonl(br_port_get_rcu(outdev)->br->dev->ifindex));
} else {
/* Case 2: outdev is bridge group, we need to look for
* physical output device (when called from ipv4) */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index db71150..9ee021f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1107,7 +1107,7 @@ static int nl80211_valid_4addr(struct cfg80211_registered_device *rdev,
enum nl80211_iftype iftype)
{
if (!use_4addr) {
- if (netdev && netdev->br_port)
+ if (netdev && (netdev->priv_flags & IFF_BRIDGE_PORT))
return -EBUSY;
return 0;
}
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 3416373..0c8a1e8 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -770,8 +770,8 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
return -EOPNOTSUPP;
/* if it's part of a bridge, reject changing type to station/ibss */
- if (dev->br_port && (ntype == NL80211_IFTYPE_ADHOC ||
- ntype == NL80211_IFTYPE_STATION))
+ if ((dev->priv_flags & IFF_BRIDGE_PORT) &&
+ (ntype == NL80211_IFTYPE_ADHOC || ntype == NL80211_IFTYPE_STATION))
return -EBUSY;
if (ntype != otype) {
--
1.7.0.1
^ permalink raw reply related
* [PATCH net-next-2.6 2/3] macvlan: use rx_handler_data pointer to store macvlan_port pointer
From: Jiri Pirko @ 2010-06-10 13:35 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, eric.dumazet
In-Reply-To: <20100610133412.GC2618@psychotron.lab.eng.brq.redhat.com>
Register macvlan_port pointer as rx_handler data pointer. As macvlan_port is
removed from struct net_device, another netdev priv_flag is added to indicate
the device serves as a macvlan port.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/macvlan.c | 27 +++++++++++++++------------
include/linux/if.h | 1 +
include/linux/netdevice.h | 2 --
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 87a3bf6..dec3e8f 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -40,6 +40,10 @@ struct macvlan_port {
struct rcu_head rcu;
};
+#define macvlan_port_get_rcu(dev) ((struct macvlan_port *) rcu_dereference(dev->rx_handler_data))
+#define macvlan_port_get(dev) ((struct macvlan_port *) dev->rx_handler_data)
+#define macvlan_port_exists(dev) (dev->priv_flags & IFF_MACVLAN_PORT)
+
static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *port,
const unsigned char *addr)
{
@@ -155,7 +159,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb)
struct net_device *dev;
unsigned int len;
- port = rcu_dereference(skb->dev->macvlan_port);
+ port = macvlan_port_get_rcu(skb->dev);
if (is_multicast_ether_addr(eth->h_dest)) {
src = macvlan_hash_lookup(port, eth->h_source);
if (!src)
@@ -530,14 +534,12 @@ static int macvlan_port_create(struct net_device *dev)
INIT_LIST_HEAD(&port->vlans);
for (i = 0; i < MACVLAN_HASH_SIZE; i++)
INIT_HLIST_HEAD(&port->vlan_hash[i]);
- rcu_assign_pointer(dev->macvlan_port, port);
- err = netdev_rx_handler_register(dev, macvlan_handle_frame, NULL);
- if (err) {
- rcu_assign_pointer(dev->macvlan_port, NULL);
+ err = netdev_rx_handler_register(dev, macvlan_handle_frame, port);
+ if (err)
kfree(port);
- }
+ dev->priv_flags |= IFF_MACVLAN_PORT;
return err;
}
@@ -551,10 +553,10 @@ static void macvlan_port_rcu_free(struct rcu_head *head)
static void macvlan_port_destroy(struct net_device *dev)
{
- struct macvlan_port *port = dev->macvlan_port;
+ struct macvlan_port *port = macvlan_port_get(dev);
+ dev->priv_flags &= ~IFF_MACVLAN_PORT;
netdev_rx_handler_unregister(dev);
- rcu_assign_pointer(dev->macvlan_port, NULL);
call_rcu(&port->rcu, macvlan_port_rcu_free);
}
@@ -633,12 +635,12 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
if (!tb[IFLA_ADDRESS])
random_ether_addr(dev->dev_addr);
- if (lowerdev->macvlan_port == NULL) {
+ if (!macvlan_port_exists(lowerdev)) {
err = macvlan_port_create(lowerdev);
if (err < 0)
return err;
}
- port = lowerdev->macvlan_port;
+ port = macvlan_port_get(lowerdev);
vlan->lowerdev = lowerdev;
vlan->dev = dev;
@@ -748,10 +750,11 @@ static int macvlan_device_event(struct notifier_block *unused,
struct macvlan_dev *vlan, *next;
struct macvlan_port *port;
- port = dev->macvlan_port;
- if (port == NULL)
+ if (!macvlan_port_exists(dev))
return NOTIFY_DONE;
+ port = macvlan_port_get(dev);
+
switch (event) {
case NETDEV_CHANGE:
list_for_each_entry(vlan, &port->vlans, list)
diff --git a/include/linux/if.h b/include/linux/if.h
index be350e6..31f2e27 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -73,6 +73,7 @@
#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
#define IFF_IN_NETPOLL 0x1000 /* whether we are processing netpoll */
#define IFF_DISABLE_NETPOLL 0x2000 /* disable netpoll at run-time */
+#define IFF_MACVLAN_PORT 0x4000 /* device used as macvlan port */
#define IF_GET_IFACE 0x0001 /* for querying only */
#define IF_GET_PROTO 0x0002
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 32cc219..37faf51 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1030,8 +1030,6 @@ struct net_device {
/* bridge stuff */
struct net_bridge_port *br_port;
- /* macvlan */
- struct macvlan_port *macvlan_port;
/* GARP */
struct garp_port *garp_port;
--
1.7.0.1
^ permalink raw reply related
* [PATCH net-next-2.6 1/3] net: add rx_handler data pointer
From: Jiri Pirko @ 2010-06-10 13:34 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, eric.dumazet
In-Reply-To: <20100610133412.GC2618@psychotron.lab.eng.brq.redhat.com>
Add possibility to register rx_handler data pointer along with a rx_handler.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/macvlan.c | 2 +-
include/linux/netdevice.h | 4 +++-
net/bridge/br_if.c | 2 +-
net/core/dev.c | 6 +++++-
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 59c3155..87a3bf6 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -532,7 +532,7 @@ static int macvlan_port_create(struct net_device *dev)
INIT_HLIST_HEAD(&port->vlan_hash[i]);
rcu_assign_pointer(dev->macvlan_port, port);
- err = netdev_rx_handler_register(dev, macvlan_handle_frame);
+ err = netdev_rx_handler_register(dev, macvlan_handle_frame, NULL);
if (err) {
rcu_assign_pointer(dev->macvlan_port, NULL);
kfree(port);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c319f28..32cc219 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -960,6 +960,7 @@ struct net_device {
struct netdev_queue rx_queue;
rx_handler_func_t *rx_handler;
+ void *rx_handler_data;
struct netdev_queue *_tx ____cacheline_aligned_in_smp;
@@ -1693,7 +1694,8 @@ static inline void napi_free_frags(struct napi_struct *napi)
}
extern int netdev_rx_handler_register(struct net_device *dev,
- rx_handler_func_t *rx_handler);
+ rx_handler_func_t *rx_handler,
+ void *rx_handler_data);
extern void netdev_rx_handler_unregister(struct net_device *dev);
extern void netif_nit_deliver(struct sk_buff *skb);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index d924234..90ac003 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -431,7 +431,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
rcu_assign_pointer(dev->br_port, p);
- err = netdev_rx_handler_register(dev, br_handle_frame);
+ err = netdev_rx_handler_register(dev, br_handle_frame, NULL);
if (err)
goto err3;
diff --git a/net/core/dev.c b/net/core/dev.c
index 6f330ce..c49dda0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2705,6 +2705,7 @@ void netif_nit_deliver(struct sk_buff *skb)
* netdev_rx_handler_register - register receive handler
* @dev: device to register a handler for
* @rx_handler: receive handler to register
+ * @rx_handler_data: data pointer that is used by rx handler
*
* Register a receive hander for a device. This handler will then be
* called from __netif_receive_skb. A negative errno code is returned
@@ -2713,13 +2714,15 @@ void netif_nit_deliver(struct sk_buff *skb)
* The caller must hold the rtnl_mutex.
*/
int netdev_rx_handler_register(struct net_device *dev,
- rx_handler_func_t *rx_handler)
+ rx_handler_func_t *rx_handler,
+ void *rx_handler_data)
{
ASSERT_RTNL();
if (dev->rx_handler)
return -EBUSY;
+ rcu_assign_pointer(dev->rx_handler_data, rx_handler_data);
rcu_assign_pointer(dev->rx_handler, rx_handler);
return 0;
@@ -2739,6 +2742,7 @@ void netdev_rx_handler_unregister(struct net_device *dev)
ASSERT_RTNL();
rcu_assign_pointer(dev->rx_handler, NULL);
+ rcu_assign_pointer(dev->rx_handler_data, NULL);
}
EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister);
--
1.7.0.1
^ permalink raw reply related
* [PATCH net-next-2.6 0/3] net: use rx_handler_data pointer for bridge and macvlan ports
From: Jiri Pirko @ 2010-06-10 13:34 UTC (permalink / raw)
To: netdev; +Cc: davem, shemminger, kaber, eric.dumazet
Since recent changes ensured that only one rx_handler can be present at a time,
always either macvlan_port or br_port pointer in net_device structure is
not used. So introduce rx_handler_data pointer into net_device structure to
store this data pointer and safe some space. Also this pointer is right next
rx_handler pointer most likely on the same cache line.
Jirka
^ permalink raw reply
* Re: [PATCH v3] netfilter: Xtables: idletimer target implementation
From: Luciano Coelho @ 2010-06-10 13:32 UTC (permalink / raw)
To: ext Patrick McHardy
Cc: ext Jan Engelhardt, netfilter-devel@vger.kernel.org,
netdev@vger.kernel.org, Timo Teras
In-Reply-To: <1276173733.5453.1.camel@chilepepper>
On Thu, 2010-06-10 at 15:42 +0300, Luciano Coelho wrote:
> On Thu, 2010-06-10 at 12:07 +0200, ext Patrick McHardy wrote:
> > Luciano Coelho wrote:
> > > On Wed, 2010-06-09 at 19:48 +0200, Coelho Luciano (Nokia-D/Helsinki)
> > > wrote:
> > >
> > >> On Wed, 2010-06-09 at 17:18 +0200, ext Jan Engelhardt wrote:
> > >>
> > >>>>>> + timer = __idletimer_tg_find_by_label(info->label);
> > >>>>>> + if (!timer) {
> > >>>>>> + spin_unlock(&list_lock);
> > >>>>>> + timer = idletimer_tg_create(info);
> > >>>>>>
> > >>>>>>
> > >>>>> How does this prevent creating the same timer twice?
> > >>>>>
> > >>>> The timer will only be created if __idletimer_tg_find_by_label() returns
> > >>>> NULL, which means that no timer with that label has been found. "info"
> > >>>> won't be the same if info->label is different, right? Or can it change
> > >>>> on the fly?
> > >>>>
> > >>> One thing to be generally aware about is that things could potentially
> > >>> be instantiated by another entity between the time a label was looked up
> > >>> with negative result and the time one tries to add it.
> > >>> It may thus be required to extend keeping the lock until after
> > >>> idletimer_tg_create, in other words, lookup and create must be atomic
> > >>> to the rest of the world.
> > >>>
> > >> Ahh, sure! I missed the actual point of Patrick's question. I had the
> > >> idletimer_tg_create() inside the lock, but when I added the
> > >> sysfs_create_file() there (which can sleep), I screwed up with the
> > >> locking.
> > >>
> > >> I'll move the sysfs file creation to outside that function so I can keep
> > >> the lock until after the timer is added to the list. Thanks for
> > >> clarifying!
> > >>
> > >
> > > Hmmm... after struggling with this for a while, I think it's not really
> > > possible to simply create the sysfs file outside of the lock, because if
> > > the sysfs creation fails, we will again risk a race condition.
> > >
> > > I think the only way is to delay the sysfs file creation and do it in a
> > > workqueue.
> > >
> >
> > Why don't you simply use a mutex instead of the spinlock? It would be better
> > to only do the lookup once and store the timer pointer in the target
> > structure
> > anyways.
>
> Wow! Again I have been totally blind and focusing only in a solution for
> the spinlock problem, while using a mutex would ease things up quite a
> lot! Thanks for the suggestion, I'll re-spin my patch (pun intended?)
> with a mutex.
Yep, now I think I (finally) got it right :)
> I also agree that it makes more sense to lookup and store the timer in
> the targe.
One quick question about this: did you mean to put it in the target info
structure, in this case struct idletimer_tg_info? So is it okay to have
internal data in this structure even though it is mostly for passing
data from the userspace to the kernel?
--
Cheers,
Luca.
^ permalink raw reply
* Re: [PATCH v3] netfilter: Xtables: idletimer target implementation
From: Luciano Coelho @ 2010-06-10 12:42 UTC (permalink / raw)
To: ext Patrick McHardy
Cc: ext Jan Engelhardt, netfilter-devel@vger.kernel.org,
netdev@vger.kernel.org, Timo Teras
In-Reply-To: <4C10B954.9080603@trash.net>
On Thu, 2010-06-10 at 12:07 +0200, ext Patrick McHardy wrote:
> Luciano Coelho wrote:
> > On Wed, 2010-06-09 at 19:48 +0200, Coelho Luciano (Nokia-D/Helsinki)
> > wrote:
> >
> >> On Wed, 2010-06-09 at 17:18 +0200, ext Jan Engelhardt wrote:
> >>
> >>>>>> + timer = __idletimer_tg_find_by_label(info->label);
> >>>>>> + if (!timer) {
> >>>>>> + spin_unlock(&list_lock);
> >>>>>> + timer = idletimer_tg_create(info);
> >>>>>>
> >>>>>>
> >>>>> How does this prevent creating the same timer twice?
> >>>>>
> >>>> The timer will only be created if __idletimer_tg_find_by_label() returns
> >>>> NULL, which means that no timer with that label has been found. "info"
> >>>> won't be the same if info->label is different, right? Or can it change
> >>>> on the fly?
> >>>>
> >>> One thing to be generally aware about is that things could potentially
> >>> be instantiated by another entity between the time a label was looked up
> >>> with negative result and the time one tries to add it.
> >>> It may thus be required to extend keeping the lock until after
> >>> idletimer_tg_create, in other words, lookup and create must be atomic
> >>> to the rest of the world.
> >>>
> >> Ahh, sure! I missed the actual point of Patrick's question. I had the
> >> idletimer_tg_create() inside the lock, but when I added the
> >> sysfs_create_file() there (which can sleep), I screwed up with the
> >> locking.
> >>
> >> I'll move the sysfs file creation to outside that function so I can keep
> >> the lock until after the timer is added to the list. Thanks for
> >> clarifying!
> >>
> >
> > Hmmm... after struggling with this for a while, I think it's not really
> > possible to simply create the sysfs file outside of the lock, because if
> > the sysfs creation fails, we will again risk a race condition.
> >
> > I think the only way is to delay the sysfs file creation and do it in a
> > workqueue.
> >
>
> Why don't you simply use a mutex instead of the spinlock? It would be better
> to only do the lookup once and store the timer pointer in the target
> structure
> anyways.
Wow! Again I have been totally blind and focusing only in a solution for
the spinlock problem, while using a mutex would ease things up quite a
lot! Thanks for the suggestion, I'll re-spin my patch (pun intended?)
with a mutex.
I also agree that it makes more sense to lookup and store the timer in
the targe.
--
Cheers,
Luca.
^ permalink raw reply
* [PATCH 7/7] bridge: Fix netpoll support
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
bridge: Fix netpoll support
There are multiple problems with the newly added netpoll support:
1) Use-after-free on each netpoll packet.
2) Invoking unsafe code on netpoll/IRQ path.
3) Breaks when netpoll is enabled on the underlying device.
This patch fixes all of these problems. In particular, we now
allocate proper netpoll structures for each underlying device.
We only allow netpoll to be enabled on the bridge when all the
devices underneath it support netpoll. Once it is enabled, we
do not allow non-netpoll devices to join the bridge (until netpoll
is disabled again).
This allows us to do away with the npinfo juggling that caused
problem number 1.
Incidentally this patch fixes number 2 by bypassing unsafe code
such as multicast snooping and netfilter.
Reported-by: Qianfeng Zhang <frzhang@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
net/bridge/br_device.c | 99 +++++++++++++++++++++++++-----------------------
net/bridge/br_forward.c | 33 ++++++----------
net/bridge/br_if.c | 12 +++--
net/bridge/br_private.h | 31 +++++++++++----
4 files changed, 95 insertions(+), 80 deletions(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index dce0611..4a572f7 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -47,6 +47,12 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
skb_pull(skb, ETH_HLEN);
if (is_multicast_ether_addr(dest)) {
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ if (unlikely(in_irq())) {
+ br_flood_deliver(br, skb);
+ goto out;
+ }
+#endif
if (br_multicast_rcv(br, NULL, skb))
goto out;
@@ -199,72 +205,70 @@ static int br_set_tx_csum(struct net_device *dev, u32 data)
}
#ifdef CONFIG_NET_POLL_CONTROLLER
-static bool br_devices_support_netpoll(struct net_bridge *br)
+static void br_poll_controller(struct net_device *br_dev)
{
- struct net_bridge_port *p;
- bool ret = true;
- int count = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&br->lock, flags);
- list_for_each_entry(p, &br->port_list, list) {
- count++;
- if ((p->dev->priv_flags & IFF_DISABLE_NETPOLL) ||
- !p->dev->netdev_ops->ndo_poll_controller)
- ret = false;
- }
- spin_unlock_irqrestore(&br->lock, flags);
- return count != 0 && ret;
}
-static void br_poll_controller(struct net_device *br_dev)
+static void br_netpoll_cleanup(struct net_device *dev)
{
- struct netpoll *np = br_dev->npinfo->netpoll;
+ struct net_bridge *br = netdev_priv(dev);
+ struct net_bridge_port *p, *n;
- if (np->real_dev != br_dev)
- netpoll_poll_dev(np->real_dev);
+ list_for_each_entry_safe(p, n, &br->port_list, list) {
+ br_netpoll_disable(p);
+ }
}
-void br_netpoll_cleanup(struct net_device *dev)
+static int br_netpoll_setup(struct net_device *dev, struct netpoll_info *ni)
{
struct net_bridge *br = netdev_priv(dev);
struct net_bridge_port *p, *n;
- const struct net_device_ops *ops;
+ int err = 0;
list_for_each_entry_safe(p, n, &br->port_list, list) {
- if (p->dev) {
- ops = p->dev->netdev_ops;
- if (ops->ndo_netpoll_cleanup)
- ops->ndo_netpoll_cleanup(p->dev);
- else
- p->dev->npinfo = NULL;
- }
+ if (!p->dev)
+ continue;
+
+ err = br_netpoll_enable(p);
+ if (err)
+ goto fail;
}
+
+out:
+ return err;
+
+fail:
+ br_netpoll_cleanup(dev);
+ goto out;
}
-void br_netpoll_disable(struct net_bridge *br,
- struct net_device *dev)
+int br_netpoll_enable(struct net_bridge_port *p)
{
- if (br_devices_support_netpoll(br))
- br->dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
- if (dev->netdev_ops->ndo_netpoll_cleanup)
- dev->netdev_ops->ndo_netpoll_cleanup(dev);
- else
- dev->npinfo = NULL;
+ int err = 0;
+
+ p->np = kzalloc(sizeof(*p->np), GFP_KERNEL);
+ err = -ENOMEM;
+ if (!p->np)
+ goto out;
+
+ p->np->dev = p->dev;
+
+ err = __netpoll_setup(p->np);
+ if (err)
+ kfree(p->np);
+
+out:
+ return err;
}
-void br_netpoll_enable(struct net_bridge *br,
- struct net_device *dev)
+void br_netpoll_disable(struct net_bridge_port *p)
{
- if (br_devices_support_netpoll(br)) {
- br->dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
- if (br->dev->npinfo)
- dev->npinfo = br->dev->npinfo;
- } else if (!(br->dev->priv_flags & IFF_DISABLE_NETPOLL)) {
- br->dev->priv_flags |= IFF_DISABLE_NETPOLL;
- br_info(br,"new device %s does not support netpoll (disabling)",
- dev->name);
- }
+ if (!p->np)
+ return;
+
+ __netpoll_cleanup(p->np);
+ kfree(p->np);
+ p->np = NULL;
}
#endif
@@ -293,6 +297,7 @@ static const struct net_device_ops br_netdev_ops = {
.ndo_change_mtu = br_change_mtu,
.ndo_do_ioctl = br_dev_ioctl,
#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_netpoll_setup = br_netpoll_setup,
.ndo_netpoll_cleanup = br_netpoll_cleanup,
.ndo_poll_controller = br_poll_controller,
#endif
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index a98ef13..707b92a 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -50,14 +50,7 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
kfree_skb(skb);
else {
skb_push(skb, ETH_HLEN);
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- if (unlikely(skb->dev->priv_flags & IFF_IN_NETPOLL)) {
- netpoll_send_skb(skb->dev->npinfo->netpoll, skb);
- skb->dev->priv_flags &= ~IFF_IN_NETPOLL;
- } else
-#endif
- dev_queue_xmit(skb);
+ dev_queue_xmit(skb);
}
}
@@ -73,23 +66,23 @@ int br_forward_finish(struct sk_buff *skb)
static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
{
+ skb->dev = to->dev;
+
#ifdef CONFIG_NET_POLL_CONTROLLER
- struct net_bridge *br = to->br;
- if (unlikely(br->dev->priv_flags & IFF_IN_NETPOLL)) {
- struct netpoll *np;
- to->dev->npinfo = skb->dev->npinfo;
- np = skb->dev->npinfo->netpoll;
- np->real_dev = np->dev = to->dev;
- to->dev->priv_flags |= IFF_IN_NETPOLL;
+ if (unlikely(in_irq())) {
+ if ((packet_length(skb) > skb->dev->mtu && !skb_is_gso(skb)) ||
+ !to->np)
+ kfree_skb(skb);
+ else {
+ skb_push(skb, ETH_HLEN);
+ netpoll_send_skb(to->np, skb);
+ }
+ return;
}
#endif
- skb->dev = to->dev;
+
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
br_forward_finish);
-#ifdef CONFIG_NET_POLL_CONTROLLER
- if (skb->dev->npinfo)
- skb->dev->npinfo->netpoll->dev = br->dev;
-#endif
}
static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 18b245e..13102e0 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -154,7 +154,8 @@ static void del_nbp(struct net_bridge_port *p)
kobject_uevent(&p->kobj, KOBJ_REMOVE);
kobject_del(&p->kobj);
- br_netpoll_disable(br, dev);
+ br_netpoll_disable(p);
+
call_rcu(&p->rcu, destroy_nbp_rcu);
}
@@ -167,8 +168,6 @@ static void del_br(struct net_bridge *br, struct list_head *head)
del_nbp(p);
}
- br_netpoll_cleanup(br->dev);
-
del_timer_sync(&br->gc_timer);
br_sysfs_delbr(br->dev);
@@ -428,6 +427,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (err)
goto err2;
+ if (br_netpoll_info(br) && ((err = br_netpoll_enable(p))))
+ goto err3;
+
rcu_assign_pointer(dev->br_port, p);
dev_disable_lro(dev);
@@ -448,9 +450,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
kobject_uevent(&p->kobj, KOBJ_ADD);
- br_netpoll_enable(br, dev);
-
return 0;
+err3:
+ sysfs_remove_link(br->ifobj, p->dev->name);
err2:
br_fdb_delete_by_port(br, p, 1);
err1:
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 0f4a74b..1c55c98 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -143,6 +143,10 @@ struct net_bridge_port
#ifdef CONFIG_SYSFS
char sysfs_name[IFNAMSIZ];
#endif
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ struct netpoll *np;
+#endif
};
struct br_cpu_netstats {
@@ -273,16 +277,27 @@ extern void br_dev_setup(struct net_device *dev);
extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
struct net_device *dev);
#ifdef CONFIG_NET_POLL_CONTROLLER
-extern void br_netpoll_cleanup(struct net_device *dev);
-extern void br_netpoll_enable(struct net_bridge *br,
- struct net_device *dev);
-extern void br_netpoll_disable(struct net_bridge *br,
- struct net_device *dev);
+static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
+{
+ return br->dev->npinfo;
+}
+
+extern int br_netpoll_enable(struct net_bridge_port *p);
+extern void br_netpoll_disable(struct net_bridge_port *p);
#else
-#define br_netpoll_cleanup(br)
-#define br_netpoll_enable(br, dev)
-#define br_netpoll_disable(br, dev)
+static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
+{
+ return NULL;
+}
+
+static inline int br_netpoll_enable(struct net_bridge_port *p)
+{
+ return 0;
+}
+static inline void br_netpoll_disable(struct net_bridge_port *p)
+{
+}
#endif
/* br_fdb.c */
^ permalink raw reply related
* [PATCH 6/7] netpoll: Allow netpoll_setup/cleanup recursion
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
netpoll: Allow netpoll_setup/cleanup recursion
This patch adds the functions __netpoll_setup/__netpoll_cleanup
which is designed to be called recursively through ndo_netpoll_seutp.
They must be called with RTNL held, and the caller must initialise
np->dev and ensure that it has a valid reference count.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/linux/netpoll.h | 2
net/core/netpoll.c | 176 ++++++++++++++++++++++++++----------------------
2 files changed, 99 insertions(+), 79 deletions(-)
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 95c9f7e..f3ad74a 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -46,9 +46,11 @@ void netpoll_poll(struct netpoll *np);
void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
void netpoll_print_options(struct netpoll *np);
int netpoll_parse_options(struct netpoll *np, char *opt);
+int __netpoll_setup(struct netpoll *np);
int netpoll_setup(struct netpoll *np);
int netpoll_trap(void);
void netpoll_set_trap(int trap);
+void __netpoll_cleanup(struct netpoll *np);
void netpoll_cleanup(struct netpoll *np);
int __netpoll_rx(struct sk_buff *skb);
void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index c445896..f728208 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -724,15 +724,78 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
return -1;
}
-int netpoll_setup(struct netpoll *np)
+int __netpoll_setup(struct netpoll *np)
{
- struct net_device *ndev = NULL;
- struct in_device *in_dev;
+ struct net_device *ndev = np->dev;
struct netpoll_info *npinfo;
const struct net_device_ops *ops;
unsigned long flags;
int err;
+ if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
+ !ndev->netdev_ops->ndo_poll_controller) {
+ printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
+ np->name, np->dev_name);
+ err = -ENOTSUPP;
+ goto out;
+ }
+
+ if (!ndev->npinfo) {
+ npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
+ if (!npinfo) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ npinfo->rx_flags = 0;
+ INIT_LIST_HEAD(&npinfo->rx_np);
+
+ spin_lock_init(&npinfo->rx_lock);
+ skb_queue_head_init(&npinfo->arp_tx);
+ skb_queue_head_init(&npinfo->txq);
+ INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
+
+ atomic_set(&npinfo->refcnt, 1);
+
+ ops = np->dev->netdev_ops;
+ if (ops->ndo_netpoll_setup) {
+ err = ops->ndo_netpoll_setup(ndev, npinfo);
+ if (err)
+ goto free_npinfo;
+ }
+ } else {
+ npinfo = ndev->npinfo;
+ atomic_inc(&npinfo->refcnt);
+ }
+
+ npinfo->netpoll = np;
+
+ if (np->rx_hook) {
+ spin_lock_irqsave(&npinfo->rx_lock, flags);
+ npinfo->rx_flags |= NETPOLL_RX_ENABLED;
+ list_add_tail(&np->rx, &npinfo->rx_np);
+ spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+ }
+
+ /* last thing to do is link it to the net device structure */
+ rcu_assign_pointer(ndev->npinfo, npinfo);
+ rtnl_unlock();
+
+ return 0;
+
+free_npinfo:
+ kfree(npinfo);
+out:
+ return err;
+}
+EXPORT_SYMBOL_GPL(__netpoll_setup);
+
+int netpoll_setup(struct netpoll *np)
+{
+ struct net_device *ndev = NULL;
+ struct in_device *in_dev;
+ int err;
+
if (np->dev_name)
ndev = dev_get_by_name(&init_net, np->dev_name);
if (!ndev) {
@@ -805,61 +868,14 @@ int netpoll_setup(struct netpoll *np)
refill_skbs();
rtnl_lock();
- if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
- !ndev->netdev_ops->ndo_poll_controller) {
- printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
- np->name, np->dev_name);
- err = -ENOTSUPP;
- goto unlock;
- }
-
- if (!ndev->npinfo) {
- npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
- if (!npinfo) {
- err = -ENOMEM;
- goto unlock;
- }
-
- npinfo->rx_flags = 0;
- INIT_LIST_HEAD(&npinfo->rx_np);
-
- spin_lock_init(&npinfo->rx_lock);
- skb_queue_head_init(&npinfo->arp_tx);
- skb_queue_head_init(&npinfo->txq);
- INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
-
- atomic_set(&npinfo->refcnt, 1);
-
- ops = np->dev->netdev_ops;
- if (ops->ndo_netpoll_setup) {
- err = ops->ndo_netpoll_setup(ndev, npinfo);
- if (err)
- goto free_npinfo;
- }
- } else {
- npinfo = ndev->npinfo;
- atomic_inc(&npinfo->refcnt);
- }
-
- npinfo->netpoll = np;
-
- if (np->rx_hook) {
- spin_lock_irqsave(&npinfo->rx_lock, flags);
- npinfo->rx_flags |= NETPOLL_RX_ENABLED;
- list_add_tail(&np->rx, &npinfo->rx_np);
- spin_unlock_irqrestore(&npinfo->rx_lock, flags);
- }
-
- /* last thing to do is link it to the net device structure */
- rcu_assign_pointer(ndev->npinfo, npinfo);
+ err = __netpoll_setup(np);
rtnl_unlock();
+ if (err)
+ goto put;
+
return 0;
-free_npinfo:
- kfree(npinfo);
-unlock:
- rtnl_unlock();
put:
dev_put(ndev);
return err;
@@ -872,40 +888,32 @@ static int __init netpoll_init(void)
}
core_initcall(netpoll_init);
-void netpoll_cleanup(struct netpoll *np)
+void __netpoll_cleanup(struct netpoll *np)
{
struct netpoll_info *npinfo;
unsigned long flags;
- int free = 0;
- if (!np->dev)
+ npinfo = np->dev->npinfo;
+ if (!npinfo)
return;
- rtnl_lock();
- npinfo = np->dev->npinfo;
- if (npinfo) {
- if (!list_empty(&npinfo->rx_np)) {
- spin_lock_irqsave(&npinfo->rx_lock, flags);
- list_del(&np->rx);
- if (list_empty(&npinfo->rx_np))
- npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
- spin_unlock_irqrestore(&npinfo->rx_lock, flags);
- }
+ if (!list_empty(&npinfo->rx_np)) {
+ spin_lock_irqsave(&npinfo->rx_lock, flags);
+ list_del(&np->rx);
+ if (list_empty(&npinfo->rx_np))
+ npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
+ spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+ }
- free = atomic_dec_and_test(&npinfo->refcnt);
- if (free) {
- const struct net_device_ops *ops;
+ if (atomic_dec_and_test(&npinfo->refcnt)) {
+ const struct net_device_ops *ops;
- ops = np->dev->netdev_ops;
- if (ops->ndo_netpoll_cleanup)
- ops->ndo_netpoll_cleanup(np->dev);
+ ops = np->dev->netdev_ops;
+ if (ops->ndo_netpoll_cleanup)
+ ops->ndo_netpoll_cleanup(np->dev);
- rcu_assign_pointer(np->dev->npinfo, NULL);
- }
- }
- rtnl_unlock();
+ rcu_assign_pointer(np->dev->npinfo, NULL);
- if (free) {
/* avoid racing with NAPI reading npinfo */
synchronize_rcu_bh();
@@ -917,9 +925,19 @@ void netpoll_cleanup(struct netpoll *np)
__skb_queue_purge(&npinfo->txq);
kfree(npinfo);
}
+}
+EXPORT_SYMBOL_GPL(__netpoll_cleanup);
- dev_put(np->dev);
+void netpoll_cleanup(struct netpoll *np)
+{
+ if (!np->dev)
+ return;
+ rtnl_lock();
+ __netpoll_cleanup(np);
+ rtnl_unlock();
+
+ dev_put(np->dev);
np->dev = NULL;
}
^ permalink raw reply related
* [PATCH 5/7] netpoll: Add ndo_netpoll_setup
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
netpoll: Add ndo_netpoll_setup
This patch adds ndo_netpoll_setup as the initialisation primitive
to complement ndo_netpoll_cleanup.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/linux/netdevice.h | 2 ++
net/core/netpoll.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 40291f3..619d3f1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -728,6 +728,8 @@ struct net_device_ops {
unsigned short vid);
#ifdef CONFIG_NET_POLL_CONTROLLER
void (*ndo_poll_controller)(struct net_device *dev);
+ int (*ndo_netpoll_setup)(struct net_device *dev,
+ struct netpoll_info *info);
void (*ndo_netpoll_cleanup)(struct net_device *dev);
#endif
int (*ndo_set_vf_mac)(struct net_device *dev,
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 9dcd767..c445896 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -729,6 +729,7 @@ int netpoll_setup(struct netpoll *np)
struct net_device *ndev = NULL;
struct in_device *in_dev;
struct netpoll_info *npinfo;
+ const struct net_device_ops *ops;
unsigned long flags;
int err;
@@ -828,6 +829,13 @@ int netpoll_setup(struct netpoll *np)
INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
atomic_set(&npinfo->refcnt, 1);
+
+ ops = np->dev->netdev_ops;
+ if (ops->ndo_netpoll_setup) {
+ err = ops->ndo_netpoll_setup(ndev, npinfo);
+ if (err)
+ goto free_npinfo;
+ }
} else {
npinfo = ndev->npinfo;
atomic_inc(&npinfo->refcnt);
@@ -848,6 +856,8 @@ int netpoll_setup(struct netpoll *np)
return 0;
+free_npinfo:
+ kfree(npinfo);
unlock:
rtnl_unlock();
put:
^ permalink raw reply related
* [PATCH 4/7] netpoll: Add locking for netpoll_setup/cleanup
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
netpoll: Add locking for netpoll_setup/cleanup
As it stands, netpoll_setup and netpoll_cleanup have no locking
protection whatsoever. So chaos ensures if two entities try to
perform them on the same device.
This patch adds RTNL to the equation. The code has be rearranged
so that bits that do not need RTNL protection are now moved to
the top of netpoll_setup.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
net/core/netpoll.c | 151 ++++++++++++++++++++++++++---------------------------
1 file changed, 76 insertions(+), 75 deletions(-)
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 4b7623d..9dcd767 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -729,7 +729,6 @@ int netpoll_setup(struct netpoll *np)
struct net_device *ndev = NULL;
struct in_device *in_dev;
struct netpoll_info *npinfo;
- struct netpoll *npe, *tmp;
unsigned long flags;
int err;
@@ -741,38 +740,6 @@ int netpoll_setup(struct netpoll *np)
return -ENODEV;
}
- np->dev = ndev;
- if (!ndev->npinfo) {
- npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
- if (!npinfo) {
- err = -ENOMEM;
- goto put;
- }
-
- npinfo->rx_flags = 0;
- INIT_LIST_HEAD(&npinfo->rx_np);
-
- spin_lock_init(&npinfo->rx_lock);
- skb_queue_head_init(&npinfo->arp_tx);
- skb_queue_head_init(&npinfo->txq);
- INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
-
- atomic_set(&npinfo->refcnt, 1);
- } else {
- npinfo = ndev->npinfo;
- atomic_inc(&npinfo->refcnt);
- }
-
- npinfo->netpoll = np;
-
- if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
- !ndev->netdev_ops->ndo_poll_controller) {
- printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
- np->name, np->dev_name);
- err = -ENOTSUPP;
- goto release;
- }
-
if (!netif_running(ndev)) {
unsigned long atmost, atleast;
@@ -786,7 +753,7 @@ int netpoll_setup(struct netpoll *np)
if (err) {
printk(KERN_ERR "%s: failed to open %s\n",
np->name, ndev->name);
- goto release;
+ goto put;
}
atleast = jiffies + HZ/10;
@@ -823,7 +790,7 @@ int netpoll_setup(struct netpoll *np)
printk(KERN_ERR "%s: no IP address for %s, aborting\n",
np->name, np->dev_name);
err = -EDESTADDRREQ;
- goto release;
+ goto put;
}
np->local_ip = in_dev->ifa_list->ifa_local;
@@ -831,6 +798,43 @@ int netpoll_setup(struct netpoll *np)
printk(KERN_INFO "%s: local IP %pI4\n", np->name, &np->local_ip);
}
+ np->dev = ndev;
+
+ /* fill up the skb queue */
+ refill_skbs();
+
+ rtnl_lock();
+ if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
+ !ndev->netdev_ops->ndo_poll_controller) {
+ printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
+ np->name, np->dev_name);
+ err = -ENOTSUPP;
+ goto unlock;
+ }
+
+ if (!ndev->npinfo) {
+ npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
+ if (!npinfo) {
+ err = -ENOMEM;
+ goto unlock;
+ }
+
+ npinfo->rx_flags = 0;
+ INIT_LIST_HEAD(&npinfo->rx_np);
+
+ spin_lock_init(&npinfo->rx_lock);
+ skb_queue_head_init(&npinfo->arp_tx);
+ skb_queue_head_init(&npinfo->txq);
+ INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
+
+ atomic_set(&npinfo->refcnt, 1);
+ } else {
+ npinfo = ndev->npinfo;
+ atomic_inc(&npinfo->refcnt);
+ }
+
+ npinfo->netpoll = np;
+
if (np->rx_hook) {
spin_lock_irqsave(&npinfo->rx_lock, flags);
npinfo->rx_flags |= NETPOLL_RX_ENABLED;
@@ -838,24 +842,14 @@ int netpoll_setup(struct netpoll *np)
spin_unlock_irqrestore(&npinfo->rx_lock, flags);
}
- /* fill up the skb queue */
- refill_skbs();
-
/* last thing to do is link it to the net device structure */
rcu_assign_pointer(ndev->npinfo, npinfo);
+ rtnl_unlock();
return 0;
- release:
- if (!ndev->npinfo) {
- spin_lock_irqsave(&npinfo->rx_lock, flags);
- list_for_each_entry_safe(npe, tmp, &npinfo->rx_np, rx) {
- npe->dev = NULL;
- }
- spin_unlock_irqrestore(&npinfo->rx_lock, flags);
-
- kfree(npinfo);
- }
+unlock:
+ rtnl_unlock();
put:
dev_put(ndev);
return err;
@@ -872,43 +866,50 @@ void netpoll_cleanup(struct netpoll *np)
{
struct netpoll_info *npinfo;
unsigned long flags;
+ int free = 0;
- if (np->dev) {
- npinfo = np->dev->npinfo;
- if (npinfo) {
- if (!list_empty(&npinfo->rx_np)) {
- spin_lock_irqsave(&npinfo->rx_lock, flags);
- list_del(&np->rx);
- if (list_empty(&npinfo->rx_np))
- npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
- spin_unlock_irqrestore(&npinfo->rx_lock, flags);
- }
+ if (!np->dev)
+ return;
- if (atomic_dec_and_test(&npinfo->refcnt)) {
- const struct net_device_ops *ops;
+ rtnl_lock();
+ npinfo = np->dev->npinfo;
+ if (npinfo) {
+ if (!list_empty(&npinfo->rx_np)) {
+ spin_lock_irqsave(&npinfo->rx_lock, flags);
+ list_del(&np->rx);
+ if (list_empty(&npinfo->rx_np))
+ npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
+ spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+ }
- ops = np->dev->netdev_ops;
- if (ops->ndo_netpoll_cleanup)
- ops->ndo_netpoll_cleanup(np->dev);
+ free = atomic_dec_and_test(&npinfo->refcnt);
+ if (free) {
+ const struct net_device_ops *ops;
- rcu_assign_pointer(np->dev->npinfo, NULL);
+ ops = np->dev->netdev_ops;
+ if (ops->ndo_netpoll_cleanup)
+ ops->ndo_netpoll_cleanup(np->dev);
- /* avoid racing with NAPI reading npinfo */
- synchronize_rcu_bh();
+ rcu_assign_pointer(np->dev->npinfo, NULL);
+ }
+ }
+ rtnl_unlock();
- skb_queue_purge(&npinfo->arp_tx);
- skb_queue_purge(&npinfo->txq);
- cancel_rearming_delayed_work(&npinfo->tx_work);
+ if (free) {
+ /* avoid racing with NAPI reading npinfo */
+ synchronize_rcu_bh();
- /* clean after last, unfinished work */
- __skb_queue_purge(&npinfo->txq);
- kfree(npinfo);
- }
- }
+ skb_queue_purge(&npinfo->arp_tx);
+ skb_queue_purge(&npinfo->txq);
+ cancel_rearming_delayed_work(&npinfo->tx_work);
- dev_put(np->dev);
+ /* clean after last, unfinished work */
+ __skb_queue_purge(&npinfo->txq);
+ kfree(npinfo);
}
+ dev_put(np->dev);
+
np->dev = NULL;
}
^ permalink raw reply related
* [PATCH 2/7] bridge: Remove redundant npinfo NULL setting
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
bridge: Remove redundant npinfo NULL setting
Now that netpoll always zaps npinfo we no longer needs to do it
in bridge.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
net/bridge/br_device.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index eedf2c9..dce0611 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -231,7 +231,6 @@ void br_netpoll_cleanup(struct net_device *dev)
struct net_bridge_port *p, *n;
const struct net_device_ops *ops;
- br->dev->npinfo = NULL;
list_for_each_entry_safe(p, n, &br->port_list, list) {
if (p->dev) {
ops = p->dev->netdev_ops;
^ permalink raw reply related
* [PATCH 3/7] netpoll: Fix RCU usage
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
netpoll: Fix RCU usage
The use of RCU in netpoll is incorrect in a number of places:
1) The initial setting is lacking a write barrier.
2) The synchronize_rcu is in the wrong place.
3) Read barriers are missing.
4) Some places are even missing rcu_read_lock.
5) npinfo is zeroed after freeing.
This patch fixes those issues. As most users are in BH context,
this also converts the RCU usage to the BH variant.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/linux/netpoll.h | 13 ++++++++-----
net/core/netpoll.c | 20 ++++++++++++--------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index e9e2312..95c9f7e 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -57,12 +57,15 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
#ifdef CONFIG_NETPOLL
static inline bool netpoll_rx(struct sk_buff *skb)
{
- struct netpoll_info *npinfo = skb->dev->npinfo;
+ struct netpoll_info *npinfo;
unsigned long flags;
bool ret = false;
+ rcu_read_lock_bh();
+ npinfo = rcu_dereference(skb->dev->npinfo);
+
if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags))
- return false;
+ goto out;
spin_lock_irqsave(&npinfo->rx_lock, flags);
/* check rx_flags again with the lock held */
@@ -70,12 +73,14 @@ static inline bool netpoll_rx(struct sk_buff *skb)
ret = true;
spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+out:
+ rcu_read_unlock_bh();
return ret;
}
static inline int netpoll_rx_on(struct sk_buff *skb)
{
- struct netpoll_info *npinfo = skb->dev->npinfo;
+ struct netpoll_info *npinfo = rcu_dereference(skb->dev->npinfo);
return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags);
}
@@ -91,7 +96,6 @@ static inline void *netpoll_poll_lock(struct napi_struct *napi)
{
struct net_device *dev = napi->dev;
- rcu_read_lock(); /* deal with race on ->npinfo */
if (dev && dev->npinfo) {
spin_lock(&napi->poll_lock);
napi->poll_owner = smp_processor_id();
@@ -108,7 +112,6 @@ static inline void netpoll_poll_unlock(void *have)
napi->poll_owner = -1;
spin_unlock(&napi->poll_lock);
}
- rcu_read_unlock();
}
#else
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 748c930..4b7623d 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -292,6 +292,7 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
unsigned long tries;
struct net_device *dev = np->dev;
const struct net_device_ops *ops = dev->netdev_ops;
+ /* It is up to the caller to keep npinfo alive. */
struct netpoll_info *npinfo = np->dev->npinfo;
if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
@@ -841,10 +842,7 @@ int netpoll_setup(struct netpoll *np)
refill_skbs();
/* last thing to do is link it to the net device structure */
- ndev->npinfo = npinfo;
-
- /* avoid racing with NAPI reading npinfo */
- synchronize_rcu();
+ rcu_assign_pointer(ndev->npinfo, npinfo);
return 0;
@@ -888,6 +886,16 @@ void netpoll_cleanup(struct netpoll *np)
if (atomic_dec_and_test(&npinfo->refcnt)) {
const struct net_device_ops *ops;
+
+ ops = np->dev->netdev_ops;
+ if (ops->ndo_netpoll_cleanup)
+ ops->ndo_netpoll_cleanup(np->dev);
+
+ rcu_assign_pointer(np->dev->npinfo, NULL);
+
+ /* avoid racing with NAPI reading npinfo */
+ synchronize_rcu_bh();
+
skb_queue_purge(&npinfo->arp_tx);
skb_queue_purge(&npinfo->txq);
cancel_rearming_delayed_work(&npinfo->tx_work);
@@ -895,10 +903,6 @@ void netpoll_cleanup(struct netpoll *np)
/* clean after last, unfinished work */
__skb_queue_purge(&npinfo->txq);
kfree(npinfo);
- ops = np->dev->netdev_ops;
- if (ops->ndo_netpoll_cleanup)
- ops->ndo_netpoll_cleanup(np->dev);
- np->dev->npinfo = NULL;
}
}
^ permalink raw reply related
* [PATCH 1/7] netpoll: Set npinfo to NULL even with ndo_netpoll_cleanup
From: Herbert Xu @ 2010-06-10 12:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
In-Reply-To: <20100610124047.GA16658@gondor.apana.org.au>
netpoll: Set npinfo to NULL even with ndo_netpoll_cleanup
Sinec we have to null npinfo regardless of whether there is a
ndo_netpoll_cleanup, it makes sense to do this unconditionally
in netpoll_cleanup rather than having every driver do it by
themselves.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
net/core/netpoll.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 94825b1..748c930 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -898,8 +898,7 @@ void netpoll_cleanup(struct netpoll *np)
ops = np->dev->netdev_ops;
if (ops->ndo_netpoll_cleanup)
ops->ndo_netpoll_cleanup(np->dev);
- else
- np->dev->npinfo = NULL;
+ np->dev->npinfo = NULL;
}
}
^ permalink raw reply related
* [0/8] netpoll/bridge fixes
From: Herbert Xu @ 2010-06-10 12:40 UTC (permalink / raw)
To: Michael S. Tsirkin, Qianfeng Zhang, David S. Miller, netdev,
WANG Cong, Stephen
[-- Attachment #1: Type: text/plain, Size: 716 bytes --]
Hi:
Qianfeng Zhang reported that he was seeing crashes with the
attached backtrace.
I tracked this down to the recently added netpoll support in
the bridge device. It's a classic use-after-free problem.
Trying to solve it brought out a host of other issues, some of
which existed prior to the new bridge code. The following patches
attempt to address some of these issues.
Warning, this is completely untested (apart from compiling with
everything enabled) so please look but don't merge :)
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[-- Attachment #2: dmesg.txt --]
[-- Type: text/plain, Size: 5337 bytes --]
BUG: unable to handle kernel NULL pointer dereference at 0000000000000400
IP: [<ffffffffa0456824>] __br_deliver+0x64/0xe0 [bridge]
PGD 31e038067 PUD 31e5d6067 PMD 0
Oops: 0000 [#1] SMP
last sysfs file: /sys/kernel/mm/ksm/run
CPU 3
Modules linked in: vhost_net(U) macvtap(U) macvlan(U) tun(U) ip6table_filter(U) ip6_tables(U) ebtable_nat(U) ebtables(U) ipt_MASQUERADE(U) iptable_nat(U) nf_nat(U) nfsd(U) exportfs(U) nfs(U) lockd(U) fscache(U) nfs_acl(U) auth_rpcgss(U) sunrpc(U) cpufreq_ondemand(U) acpi_cpufreq(U) freq_table(U)
bridge(U) stp(U) llc(U) ipv6(U) dm_mirror(U) dm_region_hash(U) dm_log(U) kvm_intel(U) kvm(U) snd_hda_codec_realtek(U) snd_hda_intel(U) snd_hda_codec(U) snd_hwdep(U) snd_seq(U) snd_seq_device(U) snd_pcm(U) igb(U) i7core_edac(U) edac_core(U) iTCO_wdt(U) dca(U) snd_timer(U) snd(U) soundcore(U)
snd_page_alloc(U) iTCO_vendor_support(U) sr_mod(U) tg3(U) sg(U) cdrom(U) serio_raw(U) wmi(U) ext4(U) mbcache(U) jbd2(U) sd_mod(U) mptsas(U) crc_t10dif(U) mptscsih(U) mptbase(U) scsi_transport_sas(U) firewire_ohci(U) firewire_core(U) crc_itu_t(U) ahci(U) nouveau(U) ttm(U) drm_kms_helper(U) drm(U)
i2c_algo_bit(U) i2c_core(U) dm_mod(U) [last unloaded: microcode]
Modules linked in: vhost_net(U) macvtap(U) macvlan(U) tun(U) ip6table_filter(U) ip6_tables(U) ebtable_nat(U) ebtables(U) ipt_MASQUERADE(U) iptable_nat(U) nf_nat(U) nfsd(U) exportfs(U) nfs(U) lockd(U) fscache(U) nfs_acl(U) auth_rpcgss(U) sunrpc(U) cpufreq_ondemand(U) acpi_cpufreq(U) freq_table(U)
bridge(U) stp(U) llc(U) ipv6(U) dm_mirror(U) dm_region_hash(U) dm_log(U) kvm_intel(U) kvm(U) snd_hda_codec_realtek(U) snd_hda_intel(U) snd_hda_codec(U) snd_hwdep(U) snd_seq(U) snd_seq_device(U) snd_pcm(U) igb(U) i7core_edac(U) edac_core(U) iTCO_wdt(U) dca(U) snd_timer(U) snd(U) soundcore(U)
snd_page_alloc(U) iTCO_vendor_support(U) sr_mod(U) tg3(U) sg(U) cdrom(U) serio_raw(U) wmi(U) ext4(U) mbcache(U) jbd2(U) sd_mod(U) mptsas(U) crc_t10dif(U) mptscsih(U) mptbase(U) scsi_transport_sas(U) firewire_ohci(U) firewire_core(U) crc_itu_t(U) ahci(U) nouveau(U) ttm(U) drm_kms_helper(U) drm(U)
i2c_algo_bit(U) i2c_core(U) dm_mod(U) [last unloaded: microcode]
Pid: 2234, comm: netserver Tainted: G W 2.6.32-31.el6.x86_64 #1 HP Z800 Workstation
RIP: 0010:[<ffffffffa0456824>] [<ffffffffa0456824>] __br_deliver+0x64/0xe0 [bridge]
RSP: 0018:ffff880320ab7698 EFLAGS: 00010292
RAX: 0000000000000000 RBX: ffff88032035a6c0 RCX: ffff880320056140
RDX: 000000000000a971 RSI: 0000000000000282 RDI: ffff88031af1769c
RBP: ffff880320ab76b8 R08: ffff88031af1769c R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffff88031d17aa80
R13: ffff88031d17aab8 R14: ffff88031af7e8ce R15: ffff88032035a000
FS: 00007ff18f067700(0000) GS:ffff880028260000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000400 CR3: 000000031f101000 CR4: 00000000000026e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process netserver (pid: 2234, threadinfo ffff880320ab6000, task ffff88031af62a60)
Stack:
0000000380000000 ffff88032056f300 ffff88031d17aa80 ffff88032035a6c0
<0> ffff880320ab76c8 ffffffffa04568d5 ffff880320ab76f8 ffffffffa04555ac
<0> ffffffff818bbde0 0000000000000003 ffffffff818bbe20 ffff88031d17aa80
Call Trace:
[<ffffffffa04568d5>] br_deliver+0x35/0x40 [bridge]
[<ffffffffa04555ac>] br_dev_xmit+0xbc/0x100 [bridge]
[<ffffffff8140f708>] dev_hard_start_xmit+0x2b8/0x370
[<ffffffff81412c3e>] dev_queue_xmit+0x3be/0x4a0
[<ffffffff81417545>] neigh_resolve_output+0x105/0x370
[<ffffffff8144e9f0>] ? ip_finish_output+0x0/0x310
[<ffffffff8144eb2c>] ip_finish_output+0x13c/0x310
[<ffffffff8144edb8>] ip_output+0xb8/0xc0
[<ffffffff8144dd0f>] ? __ip_local_out+0x9f/0xb0
[<ffffffff8144dd45>] ip_local_out+0x25/0x30
[<ffffffff8144e590>] ip_queue_xmit+0x190/0x420
[<ffffffff814630e1>] tcp_transmit_skb+0x3f1/0x790
[<ffffffff814649f9>] tcp_send_ack+0xd9/0x120
[<ffffffff8145c31e>] __tcp_ack_snd_check+0x5e/0xa0
[<ffffffff81461401>] tcp_rcv_established+0x271/0x820
[<ffffffff814694b3>] tcp_v4_do_rcv+0x2e3/0x430
[<ffffffff814694b3>] ? tcp_v4_do_rcv+0x2e3/0x430
[<ffffffff814003ad>] release_sock+0x5d/0xc0
[<ffffffff81458744>] tcp_recvmsg+0x864/0xe80
[<ffffffff81013c8e>] ? apic_timer_interrupt+0xe/0x20
[<ffffffff813ffa79>] sock_common_recvmsg+0x39/0x50
[<ffffffff813fd42e>] ? sock_recvmsg+0x13e/0x160
[<ffffffff813fd423>] sock_recvmsg+0x133/0x160
[<ffffffff8110c31e>] ? filemap_fault+0xbe/0x510
[<ffffffff8108ff80>] ? autoremove_wake_function+0x0/0x40
[<ffffffff8110aa87>] ? unlock_page+0x27/0x30
[<ffffffff81131869>] ? __do_fault+0x439/0x500
[<ffffffff81013c8e>] ? apic_timer_interrupt+0xe/0x20
[<ffffffff814003ff>] ? release_sock+0xaf/0xc0
[<ffffffff813fd771>] sys_recvfrom+0xe1/0x170
[<ffffffff8101187e>] ? __switch_to+0x26e/0x320
[<ffffffff810d267e>] ? audit_syscall_entry+0x2e/0x280
[<ffffffff810d28a2>] ? audit_syscall_entry+0x252/0x280
[<ffffffff81013172>] system_call_fastpath+0x16/0x1b
Code: c9 49 c7 c1 30 66 45 a0 4c 89 e2 be 03 00 00 00 bf 07 00 00 00 c7 04 24 00 00 00 80 e8 c6 eb fd e0 83 f8 01 74 31 49 8b 44 24 20 <48> 8b 80 00 04 00 00 48 85 c0 74 0e 48 8b 80 b8 00 00 00 48 8b
RIP [<ffffffffa0456824>] __br_deliver+0x64/0xe0 [bridge]
RSP <ffff880320ab7698>
CR2: 0000000000000400
^ permalink raw reply
* Re: Packet capture and Bonding asymmetries
From: Paul LeoNerd Evans @ 2010-06-10 12:10 UTC (permalink / raw)
To: Jay Vosburgh, netdev
In-Reply-To: <17501.1276123951@death.nxdomain.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3073 bytes --]
On Wed, Jun 09, 2010 at 03:52:31PM -0700, Jay Vosburgh wrote:
> >I believe this should be fixable with a one-line patch; just adding a
> >call to netif_nit_deliver(skb) from within the bonding driver... though
> >just offhand I'm unable to find exactly the line where packets received
> >on slaves gets passed up to the master. :)
>
> This won't work, because bonding does not have a receive
> function in the usual sense. Instead, the slaves do their normal
> receive logic, and then in __netif_receive_skb, packets are assigned to
> the bonding master if the device is a slave.
Ah; that would explain why I'm having trouble finding it then :)
> For your own private testing, you could add a call to
> __netif_nit_deliver in netif_receive_skb prior to this part:
<snip>
Rather than put it -before- that part, why not inside the if (master)
arm?
-----
diff -urp linux-2.6.33.2.orig/net/core/dev.c linux-2.6.33.2/net/core/dev.c
--- linux-2.6.33.2.orig/net/core/dev.c 2010-04-02 00:02:33.000000000 +0100
+++ linux-2.6.33.2/net/core/dev.c 2010-06-10 12:58:24.000000000 +0100
@@ -2443,6 +2443,7 @@ int netif_receive_skb(struct sk_buff *sk
orig_dev = skb->dev;
master = ACCESS_ONCE(orig_dev->master);
if (master) {
+ netif_nit_deliver(skb);
if (skb_bond_should_drop(skb, master))
null_or_orig = orig_dev; /* deliver only exact match */
else
-----
(This patch doesn't quite apply cleanly to latest source but if that
approach seems OK I'll rebuild it and submit properly)
> This will give you multiple captures of the same packet, as is
> seen for transmit (i.e., one on the slave, one on the bond). For
> non-bonding devices, tcpdump will see each packet twice on the same
> device, so it's not really suitable for general use.
I was hoping for a proper permanent solution - often it would have been
useful to me, that eth0 appears to receive traffic properly to tcpdump
et.al., as well as transmitting.
> If merely knowing the traffic counts is sufficient, the slaves
> do count their received packets individually, so, e.g., ifconfig will
> show how many packets a particular slave has received, regardless of
> what bonding does with them. The packet counts for the bonding device
> itself are merely a sum of all of its slaves.
I had noticed the counters, yes. That has been useful on occasions. But
at other times we've really wanted to be able to see the actual traffic.
> Also, generally speaking, IP protocol traffic that arrives on an
> inactive bonding slave is not delivered. If you're using active-backup
> mode, and your traffic makes it through, it likely arrived on the active
> slave.
Useful though that is, sometimes it's the fact that traffic appears on a
non-active slave, which is interesting, and we'd like to see what
traffic that was.
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply
* Re: [PATCH] gianfar: Revive the driver for eTSEC devices (disable timestamping)
From: Anton Vorontsov @ 2010-06-10 10:41 UTC (permalink / raw)
To: Richard Cochran; +Cc: linuxppc-dev, netdev, David Miller, Manfred Rudigier
In-Reply-To: <20100610102226.GA10653@riccoc20.at.omicron.at>
On Thu, Jun 10, 2010 at 12:22:26PM +0200, Richard Cochran wrote:
[...]
> > U-Boot 1.1.6 (Oct 9 2007 - 20:42:39) MPC83XX
> ...
> > CPU: MPC8313E, Rev: 10 at 333.333 MHz
>
> We have a newer CPU revision:
>
> U-Boot 1.3.0 (Dec 23 2008 - 13:38:14) MPC83XX
> CPU: e300c3, MPC8313E, Rev: 21 at 333.333 MHz, CSB: 166 MHz
>
> Perhaps a bug was fixed between revision 10 and 21...
>
> You mentioned having trouble on the MPC8568EMDS. Was it the same
> problem?
Yep, the symptomps were exactly the same, it didn't want to get
the DHCP answer, while I saw the DHCP requests on the host side.
But I don't know if disabling the timestamping fixes 8568, maybe
there is some additional problem with it, no idea as I don't have
8568 board in my hands any longer. I can try any proposed fixes
as soon as I get it back though.
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
^ permalink raw reply
* Re: [PATCH] gianfar: Revive the driver for eTSEC devices (disable timestamping)
From: Richard Cochran @ 2010-06-10 10:22 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: David Miller, Manfred Rudigier, netdev, linuxppc-dev
In-Reply-To: <20100610093159.GA30822@oksana.dev.rtsoft.ru>
On Thu, Jun 10, 2010 at 01:31:59PM +0400, Anton Vorontsov wrote:
> > No, we did not set TMR_CTRL[TE].
>
> So, you deliberately violate the spec and expect it to work
> everywhere? :-)
Sometimes one must read the manual with a grain of salt ;)
> > > Also, I recall that Freescale BSPs were explicitly disabling the
> > > timestamping because of a performance drop.
> >
> > The BSPs that we have, for the MPC8313ERDB and the P2020RBD both
> > include a (hacky) PTP timestmaping driver. Can you be more specific
> > about where and when Freescale is disabling timestamping?
>
> Well, bitshrine site no longer allows[1] to list patches at
> http://www.bitshrine.org/gpp/ , but there was a patch for sure.
>
> I'll try to find it in a bunch of .iso files that I have on disk
> tho.
Thanks, that will help to track the problem down.
> U-Boot 1.1.6 (Oct 9 2007 - 20:42:39) MPC83XX
...
> CPU: MPC8313E, Rev: 10 at 333.333 MHz
We have a newer CPU revision:
U-Boot 1.3.0 (Dec 23 2008 - 13:38:14) MPC83XX
CPU: e300c3, MPC8313E, Rev: 21 at 333.333 MHz, CSB: 166 MHz
Perhaps a bug was fixed between revision 10 and 21...
You mentioned having trouble on the MPC8568EMDS. Was it the same
problem?
Thanks,
Richard
^ permalink raw reply
* Re: [PATCH v3] netfilter: Xtables: idletimer target implementation
From: Patrick McHardy @ 2010-06-10 10:07 UTC (permalink / raw)
To: Luciano Coelho
Cc: ext Jan Engelhardt, netfilter-devel@vger.kernel.org,
netdev@vger.kernel.org, Timo Teras
In-Reply-To: <1276108939.11199.23.camel@powerslave>
Luciano Coelho wrote:
> On Wed, 2010-06-09 at 19:48 +0200, Coelho Luciano (Nokia-D/Helsinki)
> wrote:
>
>> On Wed, 2010-06-09 at 17:18 +0200, ext Jan Engelhardt wrote:
>>
>>>>>> + timer = __idletimer_tg_find_by_label(info->label);
>>>>>> + if (!timer) {
>>>>>> + spin_unlock(&list_lock);
>>>>>> + timer = idletimer_tg_create(info);
>>>>>>
>>>>>>
>>>>> How does this prevent creating the same timer twice?
>>>>>
>>>> The timer will only be created if __idletimer_tg_find_by_label() returns
>>>> NULL, which means that no timer with that label has been found. "info"
>>>> won't be the same if info->label is different, right? Or can it change
>>>> on the fly?
>>>>
>>> One thing to be generally aware about is that things could potentially
>>> be instantiated by another entity between the time a label was looked up
>>> with negative result and the time one tries to add it.
>>> It may thus be required to extend keeping the lock until after
>>> idletimer_tg_create, in other words, lookup and create must be atomic
>>> to the rest of the world.
>>>
>> Ahh, sure! I missed the actual point of Patrick's question. I had the
>> idletimer_tg_create() inside the lock, but when I added the
>> sysfs_create_file() there (which can sleep), I screwed up with the
>> locking.
>>
>> I'll move the sysfs file creation to outside that function so I can keep
>> the lock until after the timer is added to the list. Thanks for
>> clarifying!
>>
>
> Hmmm... after struggling with this for a while, I think it's not really
> possible to simply create the sysfs file outside of the lock, because if
> the sysfs creation fails, we will again risk a race condition.
>
> I think the only way is to delay the sysfs file creation and do it in a
> workqueue.
>
Why don't you simply use a mutex instead of the spinlock? It would be better
to only do the lookup once and store the timer pointer in the target
structure
anyways.
^ permalink raw reply
* Re: no reassembly for outgoing packets on RAW socket
From: Patrick McHardy @ 2010-06-10 10:04 UTC (permalink / raw)
To: Jiri Olsa; +Cc: netdev, Netfilter Developer Mailing List
In-Reply-To: <20100610095312.GC1915@jolsa.lab.eng.brq.redhat.com>
Jiri Olsa wrote:
> On Thu, Jun 10, 2010 at 11:14:04AM +0200, Patrick McHardy wrote:
>
>> Jiri Olsa wrote:
>>
>>> On Wed, Jun 09, 2010 at 04:16:42PM +0200, Patrick McHardy wrote:
>>>
>>>
>>>>> If this is not the way, I'd appreciatte any hint.. my goal is
>>>>> to put malformed packet on the wire (more frags bit set for a
>>>>> non fragmented packet)
>>>>>
>>>>>
>>>> I don't have any good suggestions besides adding a flag to the IPCB
>>>> and skipping defragmentation based on that.
>>>>
>>>>
>>> ok,
>>>
>>> I can see a way when I set this via setsockopt to the socket,
>>> and check the value before the defragmentation.. would such a new
>>> setsock option be acceptable?
>>>
>>> I'm not sure I can see a way via IPCB, AFAICS it's for skb bound flags
>>> which arise during the skb processing.
>>>
>>>
>> Yes, a socket option is basically what I was suggesting, using the
>> IPCB to mark the packet. But just marking the socket is fine of
>> course.
>>
>>
>>
>
> one last thought before the socket option.. :)
>
> there's IP_HDRINCL option which is enabled for RAW sockets
> (can be disabled later by setsockopt)
>
> The 'man 7 ip' says:
> "the user supplies an IP header in front of the user data"
>
> but does not mention the outgoing defragmentation.
>
> It kind of looks to me more appropriate to preserve the user suplied
> IP header.. moreover if there's a way to switch this off and have
> netfilter defragmentation + connection tracking for RAW socket.
>
> please check the following patch..
> (there's no special need for the IPSKB_NODEFRAG, it could check the
> socket->hdrincl flag directly..)
>
> thoughts?
My main concern is that users might expect netfilter to properly
track fragmented packets created using IP_HDRINCL.
^ permalink raw reply
* Re: no reassembly for outgoing packets on RAW socket
From: Jiri Olsa @ 2010-06-10 9:53 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, Netfilter Developer Mailing List
In-Reply-To: <4C10ACDC.6010108@trash.net>
On Thu, Jun 10, 2010 at 11:14:04AM +0200, Patrick McHardy wrote:
> Jiri Olsa wrote:
> > On Wed, Jun 09, 2010 at 04:16:42PM +0200, Patrick McHardy wrote:
> >
> >>> If this is not the way, I'd appreciatte any hint.. my goal is
> >>> to put malformed packet on the wire (more frags bit set for a
> >>> non fragmented packet)
> >>>
> >> I don't have any good suggestions besides adding a flag to the IPCB
> >> and skipping defragmentation based on that.
> >>
> > ok,
> >
> > I can see a way when I set this via setsockopt to the socket,
> > and check the value before the defragmentation.. would such a new
> > setsock option be acceptable?
> >
> > I'm not sure I can see a way via IPCB, AFAICS it's for skb bound flags
> > which arise during the skb processing.
> >
>
> Yes, a socket option is basically what I was suggesting, using the
> IPCB to mark the packet. But just marking the socket is fine of
> course.
>
>
one last thought before the socket option.. :)
there's IP_HDRINCL option which is enabled for RAW sockets
(can be disabled later by setsockopt)
The 'man 7 ip' says:
"the user supplies an IP header in front of the user data"
but does not mention the outgoing defragmentation.
It kind of looks to me more appropriate to preserve the user suplied
IP header.. moreover if there's a way to switch this off and have
netfilter defragmentation + connection tracking for RAW socket.
please check the following patch..
(there's no special need for the IPSKB_NODEFRAG, it could check the
socket->hdrincl flag directly..)
thoughts?
thanks,
jirka
---
diff --git a/include/net/ip.h b/include/net/ip.h
index 452f229..201a17e 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -42,6 +42,7 @@ struct inet_skb_parm {
#define IPSKB_XFRM_TRANSFORMED 4
#define IPSKB_FRAG_COMPLETE 8
#define IPSKB_REROUTED 16
+#define IPSKB_NODEFRAG 32
};
static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index cb763ae..0355bea 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -74,6 +74,9 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
return NF_ACCEPT;
#endif
#endif
+ if (IPCB(skb)->flags & IPSKB_NODEFRAG)
+ return NF_ACCEPT;
+
/* Gather fragments. */
if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb);
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 2c7a163..978e813 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -354,6 +354,13 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
if (memcpy_fromiovecend((void *)iph, from, 0, length))
goto error_free;
+ /*
+ * The header is created by user, preserve the fragments
+ * settings throught the defragmentation unit.
+ */
+ if (iph->frag_off & htons(IP_MF|IP_OFFSET))
+ IPCB(skb)->flags |= IPSKB_NODEFRAG;
+
iphlen = iph->ihl * 4;
/*
^ permalink raw reply related
* Re: [PATCH v3] netdev:bfin_mac: reclaim and free tx skb as soon as possible after transfer
From: Sonic Zhang @ 2010-06-10 9:44 UTC (permalink / raw)
To: David Miller
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b
In-Reply-To: <20100607.212238.209978119.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
On Tue, Jun 8, 2010 at 12:22 PM, David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> wrote:
> From: sonic zhang <sonic.adi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Date: Mon, 7 Jun 2010 18:38:24 +0800
>
>>
>> + if (timer_pending(&lp->tx_reclaim_timer))
>> + del_timer(&(lp->tx_reclaim_timer));
>> +
>
> Please remove the excess parenthesis around lp->tx_reclaim_timer being
> passed to del_timer().
>
> Also, you can unconditionally call del_timer(). If the timer isn't running
> the call won't do anything.
OK
>
> But you have to do something to make sure you don't race with the code that
> enables the timer, f.e. what keeps the timer from being scheduled right
> after you make this del_timer() call?
>
Sorry, I don't understand. If the timer is removed from the timer base
list, how can it be scheduled? Timeout callbacks are scheduled only
in __run_timers() in soft irq handler. Timer base list is protected
by a spinlock. After a timer is removed from the list, __run_timers()
won't triggers it any more.
Does I miss something here?
Thanks
Sonic
^ permalink raw reply
* Re: [patch] enic: cleanup vic_provinfo_alloc()
From: Dan Carpenter @ 2010-06-10 9:32 UTC (permalink / raw)
To: walter harms
Cc: Scott Feldman, Vasanthy Kolluri, Roopa Prabhu, netdev,
kernel-janitors
In-Reply-To: <4C10AEE9.4090804@bfs.de>
On Thu, Jun 10, 2010 at 11:22:49AM +0200, walter harms wrote:
> > + vp = kzalloc(VIC_PROVINFO_MAX_DATA, flags);
> > + if (!vp)
> > return NULL;
> >
> > memcpy(vp->oui, oui, sizeof(vp->oui));
> > --
>
>
> This looks like memdup() ?
>
No. VIC_PROVINFO_MAX_DATA is larger than sizeof(vp->oui).
regards,
dan carpenter
> re,
> wh
^ permalink raw reply
* Re: [PATCH] gianfar: Revive the driver for eTSEC devices (disable timestamping)
From: Anton Vorontsov @ 2010-06-10 9:31 UTC (permalink / raw)
To: Richard Cochran; +Cc: linuxppc-dev, netdev, David Miller, Manfred Rudigier
In-Reply-To: <20100610062907.GA3390@riccoc20.at.omicron.at>
[-- Attachment #1: Type: text/plain, Size: 3466 bytes --]
On Thu, Jun 10, 2010 at 08:29:08AM +0200, Richard Cochran wrote:
> On Wed, Jun 09, 2010 at 11:32:19PM +0400, Anton Vorontsov wrote:
> > Since commit cc772ab7cdcaa24d1fae332d92a1602788644f7a ("gianfar: Add
> > hardware RX timestamping support"), the driver no longer works on
> > at least MPC8313ERDB and MPC8568EMDS boards (and possibly much more
> > boards as well).
>
> What do you mean by, "no longer works?" The driver works fine for us,
For me it doesn't even able to receive DHCP answer, boot logs
attached. tcpdump on the host side:
12:56:15.266562 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:e0:0c:00:7e:21, length 548
12:56:15.266697 IP 10.0.0.2.67 > 10.0.0.32.68: BOOTP/DHCP, Reply, length 324
12:56:22.106691 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:e0:0c:00:7e:21, length 548
12:56:22.106843 IP 10.0.0.2.67 > 10.0.0.32.68: BOOTP/DHCP, Reply, length 324
12:56:33.698908 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:e0:0c:00:7e:21, length 548
12:56:33.699083 IP 10.0.0.2.67 > 10.0.0.32.68: BOOTP/DHCP, Reply, length 324
12:56:53.607275 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:e0:0c:00:7e:21, length 548
12:56:53.607430 IP 10.0.0.2.67 > 10.0.0.32.68: BOOTP/DHCP, Reply, length 324
> > That's how MPC8313 Reference Manual describes RCTRL_TS_ENABLE bit:
> >
> > Timestamp incoming packets as padding bytes. PAL field is set
> > to 8 if the PAL field is programmed to less than 8. Must be set
> > to zero if TMR_CTRL[TE]=0.
> >
> > I see that the commit above sets this bit, but it doesn't handle
> > TMR_CTRL. Manfred probably had this bit set by the firmware for
> > his boards. But obviously this isn't true for all boards in the
> > wild.
>
> No, we did not set TMR_CTRL[TE].
So, you deliberately violate the spec and expect it to work
everywhere? :-)
> For the Rx timestamps, we simply enabled them unconditionally. The
> effect of not setting TMR_CTRL[TE] was that the timestamps were
> invalid, but that should not matter if user space has not configured
> the PTP clock.
It seems to matter here, but I haven't tested if enabling the
TE bit actually solves the problem. Disabling timestamping
makes the driver work for sure though.
> > Also, I recall that Freescale BSPs were explicitly disabling the
> > timestamping because of a performance drop.
>
> The BSPs that we have, for the MPC8313ERDB and the P2020RBD both
> include a (hacky) PTP timestmaping driver. Can you be more specific
> about where and when Freescale is disabling timestamping?
Well, bitshrine site no longer allows[1] to list patches at
http://www.bitshrine.org/gpp/ , but there was a patch for sure.
I'll try to find it in a bunch of .iso files that I have on disk
tho.
> > For now, the best way to deal with this is just disable the
> > timestamping, and later we can discuss proper device tree bindings
> > and implement enabling this feature via some property.
>
> Okay, but now we want to identify what exactly works and what not. As
> mentioned, we tested this driver on four different boards and did not
> see any problems.
Sure thing, I would happily test any patches. Or if you need
to dump some register from my board, feel free to send a patch
that adds a bunch of printks and I'll send the output to you.
Thanks,
[1] http://lists.nongnu.org/archive/html/ltib/2010-04/msg00192.html
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
[-- Attachment #2: wk.log --]
[-- Type: text/plain, Size: 8094 bytes --]
U-Boot 1.1.6 (Oct 9 2007 - 20:42:39) MPC83XX
Clock configuration:
Coherent System Bus: 166 MHz
Core: 333 MHz
Local Bus Controller: 166 MHz
Local Bus: 41 MHz
DDR: 333 MHz
SEC: 55 MHz
I2C1: 166 MHz
I2C2: 166 MHz
TSEC1: 166 MHz
TSEC2: 166 MHz
USB MPH: 0 MHz
USB DR: 55 MHz
CPU: MPC8313E, Rev: 10 at 333.333 MHz
Board: Freescale MPC8313ERDB
I2C: ready
DRAM: Initializing
DDR RAM: 128 MB
FLASH: 8 MB
NAND: 32 MiB
In: serial
Out: serial
Err: serial
Net: TSEC0, TSEC1
=>
=>
=> setenv ethact TSEC1 ; setenv ipaddr 10.0.0.99 ; setenv serverip 10.0.0.2 ; setenv bootargs console=ttyS0,115200 ip=on debug ; tftp a00000 uImage ; tftp 900000 dtb ; bootm a00000 - 900000
Waiting for PHY auto negotiation to complete. done
Speed: 100, full duplex
Using TSEC1 device
TFTP from server 10.0.0.2; our IP address is 10.0.0.99
Filename 'uImage'.
Load address: 0xa00000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
##############################
done
Bytes transferred = 1482399 (169e9f hex)
Speed: 100, full duplex
Using TSEC1 device
TFTP from server 10.0.0.2; our IP address is 10.0.0.99
Filename 'dtb'.
Load address: 0x900000
Loading: ####
done
Bytes transferred = 20000 (4e20 hex)
## Booting image at 00a00000 ...
Image Name: Linux-2.6.35-rc2-00059-gf7c3a62
Created: 2010-06-10 8:59:46 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 1482335 Bytes = 1.4 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Booting using flat device tree at 0x900000
Using MPC831x RDB machine description
Linux version 2.6.35-rc2-00059-gf7c3a62 (cbou@oksana) (gcc version 4.2.0 (MontaVista 4.2.0-16.0.20.0800760 2008-04-05)) #85 Thu Jun 10 12:59:44 MSD 2010
Found legacy serial port 0 for /soc8313@e0000000/serial@4500
mem=e0004500, taddr=e0004500, irq=0, clk=166666660, speed=0
Found legacy serial port 1 for /soc8313@e0000000/serial@4600
mem=e0004600, taddr=e0004600, irq=0, clk=166666660, speed=0
bootconsole [udbg0] enabled
setup_arch: bootmem
mpc831x_rdb_setup_arch()
arch: exit
Top of RAM: 0x8000000, Total RAM: 0x8000000
Memory hole size: 0MB
Zone PFN ranges:
DMA 0x00000000 -> 0x00008000
Normal empty
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0x00000000 -> 0x00008000
On node 0 totalpages: 32768
free_area_init_node: node 0, pgdat c0302840, node_mem_map c0321000
DMA zone: 256 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 32512 pages, LIFO batch:7
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: console=ttyS0,115200 ip=on debug
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 126708k/131072k available (2980k kernel code, 4364k reserved, 136k data, 83k bss, 164k init)
Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap
* 0xfdffc000..0xfe000000 : early ioremap
* 0xc9000000..0xfdffc000 : vmalloc & ioremap
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is disabled.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:512 nr_irqs:512
IPIC (128 IRQ sources) at c9000700
time_init: decrementer frequency = 41.666665 MHz
time_init: processor frequency = 333.333320 MHz
clocksource: timebase mult[6000004] shift[22] registered
clockevent: decrementer mult[aaaaaa3] shift[32] cpu[0]
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
NET: Registered protocol family 16
alloc irq_desc for 38 on node 0
alloc kstat_irqs on node 0
irq: irq 38 on host /soc8313@e0000000/pic@700 mapped to virtual irq 38
Registering ipic with sysfs...
bio: create slab <bio-0> at 0
SCSI subsystem initialized
Switching to clocksource timebase
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
alloc irq_desc for 16 on node 0
alloc kstat_irqs on node 0
irq: irq 9 on host /soc8313@e0000000/pic@700 mapped to virtual irq 16
alloc irq_desc for 17 on node 0
alloc kstat_irqs on node 0
irq: irq 10 on host /soc8313@e0000000/pic@700 mapped to virtual irq 17
msgmni has been set to 247
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A
console [ttyS0] enabled, bootconsole disabled
console [ttyS0] enabled, bootconsole disabled
serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A
brd: module loaded
loop: module loaded
Fixed MDIO Bus: probed
alloc irq_desc for 37 on node 0
alloc kstat_irqs on node 0
irq: irq 37 on host /soc8313@e0000000/pic@700 mapped to virtual irq 37
alloc irq_desc for 36 on node 0
alloc kstat_irqs on node 0
irq: irq 36 on host /soc8313@e0000000/pic@700 mapped to virtual irq 36
alloc irq_desc for 35 on node 0
alloc kstat_irqs on node 0
irq: irq 35 on host /soc8313@e0000000/pic@700 mapped to virtual irq 35
eth0: Gianfar Ethernet Controller Version 1.2, 00:04:9f:ef:23:33
eth0: Running with NAPI enabled
eth0: RX BD ring size for Q[0]: 256
eth0: TX BD ring size for Q[0]: 256
alloc irq_desc for 34 on node 0
alloc kstat_irqs on node 0
irq: irq 34 on host /soc8313@e0000000/pic@700 mapped to virtual irq 34
alloc irq_desc for 33 on node 0
alloc kstat_irqs on node 0
irq: irq 33 on host /soc8313@e0000000/pic@700 mapped to virtual irq 33
alloc irq_desc for 32 on node 0
alloc kstat_irqs on node 0
irq: irq 32 on host /soc8313@e0000000/pic@700 mapped to virtual irq 32
eth1: Gianfar Ethernet Controller Version 1.2, 00:e0:0c:00:7e:21
eth1: Running with NAPI enabled
eth1: RX BD ring size for Q[0]: 256
eth1: TX BD ring size for Q[0]: 256
Freescale PowerQUICC MII Bus: probed
alloc irq_desc for 20 on node 0
alloc kstat_irqs on node 0
irq: irq 20 on host /soc8313@e0000000/pic@700 mapped to virtual irq 20
Freescale PowerQUICC MII Bus: probed
md: linear personality registered for level -1
md: raid0 personality registered for level 0
md: raid1 personality registered for level 1
TCP cubic registered
NET: Registered protocol family 17
Sending DHCP requests .
PHY: 0:01 - Link is Up - 1000/Full
PHY: mdio@e0024520:04 - Link is Up - 100/Full
., OK
IP-Config: Got DHCP answer from 10.0.0.2, my address is 10.0.0.32
IP-Config: Complete:
device=eth1, addr=10.0.0.32, mask=255.255.255.0, gw=10.0.0.2,
host=10.0.0.32, domain=local.net, nis-domain=(none),
bootserver=10.0.0.2, rootserver=10.0.0.2, rootpath=/opt/montavista/cge/devkit/ppc/83xx/target/
md: Waiting for all devices to be available before autodetect
md: If you don't use raid, use raid=noautodetect
md: Autodetecting RAID arrays.
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
Looking up port of RPC 100003/2 on 10.0.0.2
Looking up port of RPC 100005/1 on 10.0.0.2
VFS: Mounted root (nfs filesystem) readonly on device 0:10.
Freeing unused kernel memory: 164k init
[-- Attachment #3: nwk.log --]
[-- Type: text/plain, Size: 7537 bytes --]
U-Boot 1.1.6 (Oct 9 2007 - 20:42:39) MPC83XX
Clock configuration:
Coherent System Bus: 166 MHz
Core: 333 MHz
Local Bus Controller: 166 MHz
Local Bus: 41 MHz
DDR: 333 MHz
SEC: 55 MHz
I2C1: 166 MHz
I2C2: 166 MHz
TSEC1: 166 MHz
TSEC2: 166 MHz
USB MPH: 0 MHz
USB DR: 55 MHz
CPU: MPC8313E, Rev: 10 at 333.333 MHz
Board: Freescale MPC8313ERDB
I2C: ready
DRAM: Initializing
DDR RAM: 128 MB
FLASH: 8 MB
NAND: 32 MiB
In: serial
Out: serial
Err: serial
Net: TSEC0, TSEC1
=>
=>
=> setenv ethact TSEC1 ; setenv ipaddr 10.0.0.99 ; setenv serverip 10.0.0.2 ; setenv bootargs console=ttyS0,115200 ip=on debug ; tftp a00000 uImage ; tftp 900000 dtb ; bootm a00000 - 900000
Waiting for PHY auto negotiation to complete. done
Speed: 100, full duplex
Using TSEC1 device
TFTP from server 10.0.0.2; our IP address is 10.0.0.99
Filename 'uImage'.
Load address: 0xa00000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
##############################
done
Bytes transferred = 1482397 (169e9d hex)
Speed: 100, full duplex
Using TSEC1 device
TFTP from server 10.0.0.2; our IP address is 10.0.0.99
Filename 'dtb'.
Load address: 0x900000
Loading: ####
done
Bytes transferred = 20000 (4e20 hex)
## Booting image at 00a00000 ...
Image Name: Linux-2.6.35-rc2-00058-ge411f2d
Created: 2010-06-10 8:52:33 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 1482333 Bytes = 1.4 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Booting using flat device tree at 0x900000
Using MPC831x RDB machine description
Linux version 2.6.35-rc2-00058-ge411f2d (cbou@oksana) (gcc version 4.2.0 (MontaVista 4.2.0-16.0.20.0800760 2008-04-05)) #84 Thu Jun 10 12:52:32 MSD 2010
Found legacy serial port 0 for /soc8313@e0000000/serial@4500
mem=e0004500, taddr=e0004500, irq=0, clk=166666660, speed=0
Found legacy serial port 1 for /soc8313@e0000000/serial@4600
mem=e0004600, taddr=e0004600, irq=0, clk=166666660, speed=0
bootconsole [udbg0] enabled
setup_arch: bootmem
mpc831x_rdb_setup_arch()
arch: exit
Top of RAM: 0x8000000, Total RAM: 0x8000000
Memory hole size: 0MB
Zone PFN ranges:
DMA 0x00000000 -> 0x00008000
Normal empty
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0x00000000 -> 0x00008000
On node 0 totalpages: 32768
free_area_init_node: node 0, pgdat c0302840, node_mem_map c0321000
DMA zone: 256 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 32512 pages, LIFO batch:7
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: console=ttyS0,115200 ip=on debug
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 126708k/131072k available (2980k kernel code, 4364k reserved, 136k data, 83k bss, 164k init)
Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap
* 0xfdffc000..0xfe000000 : early ioremap
* 0xc9000000..0xfdffc000 : vmalloc & ioremap
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is disabled.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:512 nr_irqs:512
IPIC (128 IRQ sources) at c9000700
time_init: decrementer frequency = 41.666665 MHz
time_init: processor frequency = 333.333320 MHz
clocksource: timebase mult[6000004] shift[22] registered
clockevent: decrementer mult[aaaaaa3] shift[32] cpu[0]
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
NET: Registered protocol family 16
alloc irq_desc for 38 on node 0
alloc kstat_irqs on node 0
irq: irq 38 on host /soc8313@e0000000/pic@700 mapped to virtual irq 38
Registering ipic with sysfs...
bio: create slab <bio-0> at 0
SCSI subsystem initialized
Switching to clocksource timebase
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
alloc irq_desc for 16 on node 0
alloc kstat_irqs on node 0
irq: irq 9 on host /soc8313@e0000000/pic@700 mapped to virtual irq 16
alloc irq_desc for 17 on node 0
alloc kstat_irqs on node 0
irq: irq 10 on host /soc8313@e0000000/pic@700 mapped to virtual irq 17
msgmni has been set to 247
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A
console [ttyS0] enabled, bootconsole disabled
console [ttyS0] enabled, bootconsole disabled
serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A
brd: module loaded
loop: module loaded
Fixed MDIO Bus: probed
alloc irq_desc for 37 on node 0
alloc kstat_irqs on node 0
irq: irq 37 on host /soc8313@e0000000/pic@700 mapped to virtual irq 37
alloc irq_desc for 36 on node 0
alloc kstat_irqs on node 0
irq: irq 36 on host /soc8313@e0000000/pic@700 mapped to virtual irq 36
alloc irq_desc for 35 on node 0
alloc kstat_irqs on node 0
irq: irq 35 on host /soc8313@e0000000/pic@700 mapped to virtual irq 35
eth0: Gianfar Ethernet Controller Version 1.2, 00:04:9f:ef:23:33
eth0: Running with NAPI enabled
eth0: RX BD ring size for Q[0]: 256
eth0: TX BD ring size for Q[0]: 256
alloc irq_desc for 34 on node 0
alloc kstat_irqs on node 0
irq: irq 34 on host /soc8313@e0000000/pic@700 mapped to virtual irq 34
alloc irq_desc for 33 on node 0
alloc kstat_irqs on node 0
irq: irq 33 on host /soc8313@e0000000/pic@700 mapped to virtual irq 33
alloc irq_desc for 32 on node 0
alloc kstat_irqs on node 0
irq: irq 32 on host /soc8313@e0000000/pic@700 mapped to virtual irq 32
eth1: Gianfar Ethernet Controller Version 1.2, 00:e0:0c:00:7e:21
eth1: Running with NAPI enabled
eth1: RX BD ring size for Q[0]: 256
eth1: TX BD ring size for Q[0]: 256
Freescale PowerQUICC MII Bus: probed
alloc irq_desc for 20 on node 0
alloc kstat_irqs on node 0
irq: irq 20 on host /soc8313@e0000000/pic@700 mapped to virtual irq 20
Freescale PowerQUICC MII Bus: probed
md: linear personality registered for level -1
md: raid0 personality registered for level 0
md: raid1 personality registered for level 1
TCP cubic registered
NET: Registered protocol family 17
Sending DHCP requests .
PHY: 0:01 - Link is Up - 1000/Full
PHY: mdio@e0024520:04 - Link is Up - 100/Full
..... timed out!
IP-Config: Reopening network devices...
Sending DHCP requests .
PHY: 0:01 - Link is Up - 1000/Full
PHY: mdio@e0024520:04 - Link is Up - 100/Full
.
[-- Attachment #4: Type: text/plain, Size: 150 bytes --]
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply
* Re: [patch] enic: cleanup vic_provinfo_alloc()
From: walter harms @ 2010-06-10 9:22 UTC (permalink / raw)
To: Dan Carpenter
Cc: Scott Feldman, Vasanthy Kolluri, Roopa Prabhu, netdev,
kernel-janitors
In-Reply-To: <20100610075903.GL5483@bicker>
Dan Carpenter schrieb:
> If oui were a null variable then vic_provinfo_alloc() would leak memory.
> But this function is only called from one place and oui is not null so
> I removed the check.
>
> I also moved the memory allocation down a line so it was easier to spot.
> (No one ever reads variable declarations).
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> diff --git a/drivers/net/enic/vnic_vic.c b/drivers/net/enic/vnic_vic.c
> index d769772..0a35085 100644
> --- a/drivers/net/enic/vnic_vic.c
> +++ b/drivers/net/enic/vnic_vic.c
> @@ -25,9 +25,10 @@
>
> struct vic_provinfo *vic_provinfo_alloc(gfp_t flags, u8 *oui, u8 type)
> {
> - struct vic_provinfo *vp = kzalloc(VIC_PROVINFO_MAX_DATA, flags);
> + struct vic_provinfo *vp;
>
> - if (!vp || !oui)
> + vp = kzalloc(VIC_PROVINFO_MAX_DATA, flags);
> + if (!vp)
> return NULL;
>
> memcpy(vp->oui, oui, sizeof(vp->oui));
> --
This looks like memdup() ?
re,
wh
^ permalink raw reply
* Re: no reassembly for outgoing packets on RAW socket
From: Patrick McHardy @ 2010-06-10 9:14 UTC (permalink / raw)
To: Jiri Olsa; +Cc: netdev, Netfilter Developer Mailing List
In-Reply-To: <20100610065631.GA1915@jolsa.lab.eng.brq.redhat.com>
Jiri Olsa wrote:
> On Wed, Jun 09, 2010 at 04:16:42PM +0200, Patrick McHardy wrote:
>
>>> If this is not the way, I'd appreciatte any hint.. my goal is
>>> to put malformed packet on the wire (more frags bit set for a
>>> non fragmented packet)
>>>
>> I don't have any good suggestions besides adding a flag to the IPCB
>> and skipping defragmentation based on that.
>>
> ok,
>
> I can see a way when I set this via setsockopt to the socket,
> and check the value before the defragmentation.. would such a new
> setsock option be acceptable?
>
> I'm not sure I can see a way via IPCB, AFAICS it's for skb bound flags
> which arise during the skb processing.
>
Yes, a socket option is basically what I was suggesting, using the
IPCB to mark the packet. But just marking the socket is fine of
course.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox