* [PATCH net-next 0/5] tipc: some small patches
@ 2013-09-24 9:27 Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 1/5] tipc: silence sparse warnings Jon Maloy
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Jon Maloy @ 2013-09-24 9:27 UTC (permalink / raw)
To: davem
Cc: netdev, Paul Gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, Jon Maloy
Some small and relatively straightforward patches that fix a number of
minor issues. The patches are functionally unrelated to each other.
Ying Xue (5):
tipc: silence sparse warnings
tipc: make bearer and media naming consistent
tipc: avoid unnecessary lookup for tipc bearer instance
tipc: correct return value of recv_msg routine
tipc: correct return value of link_cmd_set_value routine
net/tipc/bearer.c | 18 ++++---------
net/tipc/bearer.h | 10 ++++----
net/tipc/eth_media.c | 68 +++++++++++++++++++++++++-------------------------
net/tipc/ib_media.c | 58 +++++++++++++++++++++---------------------
net/tipc/link.c | 33 ++++++++++++++++--------
net/tipc/msg.c | 4 +--
net/tipc/socket.c | 6 ++---
7 files changed, 100 insertions(+), 97 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next 1/5] tipc: silence sparse warnings
2013-09-24 9:27 [PATCH net-next 0/5] tipc: some small patches Jon Maloy
@ 2013-09-24 9:27 ` Jon Maloy
2013-09-27 5:59 ` David Miller
2013-09-24 9:27 ` [PATCH net-next 2/5] tipc: make bearer and media naming consistent Jon Maloy
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Jon Maloy @ 2013-09-24 9:27 UTC (permalink / raw)
To: davem
Cc: netdev, Paul Gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, Andreas Bofjäll, Jon Maloy
From: Ying Xue <ying.xue@windriver.com>
Eliminate below sparse warnings:
net/tipc/link.c:1210:37: warning: cast removes address space of expression
net/tipc/link.c:1218:59: warning: incorrect type in argument 2 (different address spaces)
net/tipc/link.c:1218:59: expected void const [noderef] <asn:1>*from
net/tipc/link.c:1218:59: got unsigned char const [usertype] *[assigned] sect_crs
net/tipc/msg.c:96:61: warning: incorrect type in argument 3 (different address spaces)
net/tipc/msg.c:96:61: expected void const *from
net/tipc/msg.c:96:61: got void [noderef] <asn:1>*const iov_base
net/tipc/socket.c:341:49: warning: Using plain integer as NULL pointer
net/tipc/socket.c:1371:36: warning: Using plain integer as NULL pointer
net/tipc/socket.c:1694:57: warning: Using plain integer as NULL pointer
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Andreas Bofjäll <andreas.bofjall@ericsson.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/link.c | 5 +++--
net/tipc/msg.c | 4 ++--
net/tipc/socket.c | 6 +++---
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 0cc3d90..40521ae 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
struct tipc_msg fragm_hdr;
struct sk_buff *buf, *buf_chain, *prev;
u32 fragm_crs, fragm_rest, hsz, sect_rest;
- const unchar *sect_crs;
+ const unchar __user *sect_crs;
int curr_sect;
u32 fragm_no;
int res = 0;
@@ -1207,7 +1207,8 @@ again:
if (!sect_rest) {
sect_rest = msg_sect[++curr_sect].iov_len;
- sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
+ sect_crs =
+ (const unchar __user *)msg_sect[curr_sect].iov_base;
}
if (sect_rest < fragm_rest)
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index ced60e2..37cfb57 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -93,8 +93,8 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
skb_copy_to_linear_data(*buf, hdr, hsz);
for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
skb_copy_to_linear_data_offset(*buf, pos,
- msg_sect[cnt].iov_base,
- msg_sect[cnt].iov_len);
+ (const void __force *)msg_sect[cnt].iov_base,
+ msg_sect[cnt].iov_len);
pos += msg_sect[cnt].iov_len;
}
if (likely(res))
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 6cc7ddd..0ff921d 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -338,7 +338,7 @@ static int release(struct socket *sock)
buf = __skb_dequeue(&sk->sk_receive_queue);
if (buf == NULL)
break;
- if (TIPC_SKB_CB(buf)->handle != 0)
+ if (TIPC_SKB_CB(buf)->handle != NULL)
kfree_skb(buf);
else {
if ((sock->state == SS_CONNECTING) ||
@@ -1368,7 +1368,7 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
return TIPC_ERR_OVERLOAD;
/* Enqueue message */
- TIPC_SKB_CB(buf)->handle = 0;
+ TIPC_SKB_CB(buf)->handle = NULL;
__skb_queue_tail(&sk->sk_receive_queue, buf);
skb_set_owner_r(buf, sk);
@@ -1691,7 +1691,7 @@ restart:
/* Disconnect and send a 'FIN+' or 'FIN-' message to peer */
buf = __skb_dequeue(&sk->sk_receive_queue);
if (buf) {
- if (TIPC_SKB_CB(buf)->handle != 0) {
+ if (TIPC_SKB_CB(buf)->handle != NULL) {
kfree_skb(buf);
goto restart;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 2/5] tipc: make bearer and media naming consistent
2013-09-24 9:27 [PATCH net-next 0/5] tipc: some small patches Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 1/5] tipc: silence sparse warnings Jon Maloy
@ 2013-09-24 9:27 ` Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 3/5] tipc: avoid unnecessary lookup for tipc bearer instance Jon Maloy
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Jon Maloy @ 2013-09-24 9:27 UTC (permalink / raw)
To: davem
Cc: netdev, Paul Gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, Jon Maloy
From: Ying Xue <ying.xue@windriver.com>
TIPC 'bearer' exists as an abstract concept, while 'media'
is deemed a specific implementation of a bearer, such as Ethernet
or Infiniband media. When a component inside TIPC wants to control
a specific media, it only needs to access the generic bearer API
to achieve this. However, in the current media implementations,
the 'bearer' name is also extensively used in media specific
function and variable names.
This may create confusion, so we choose to replace the term 'bearer'
with 'media' in all function names, variable names, and prefixes
where this is what really is meant.
Note that this change is cosmetic only, and no runtime behaviour
changes are made here.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/bearer.c | 4 ++--
net/tipc/bearer.h | 8 ++++----
net/tipc/eth_media.c | 56 +++++++++++++++++++++++++-------------------------
net/tipc/ib_media.c | 46 ++++++++++++++++++++---------------------
4 files changed, 57 insertions(+), 57 deletions(-)
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 609c30c..09faa55 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -387,7 +387,7 @@ restart:
b_ptr = &tipc_bearers[bearer_id];
strcpy(b_ptr->name, name);
- res = m_ptr->enable_bearer(b_ptr);
+ res = m_ptr->enable_media(b_ptr);
if (res) {
pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
name, -res);
@@ -465,7 +465,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
pr_info("Disabling bearer <%s>\n", b_ptr->name);
spin_lock_bh(&b_ptr->lock);
b_ptr->blocked = 1;
- b_ptr->media->disable_bearer(b_ptr);
+ b_ptr->media->disable_media(b_ptr);
list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
tipc_link_delete(l_ptr);
}
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 09c869a..f800e63 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -75,8 +75,8 @@ struct tipc_bearer;
/**
* struct tipc_media - TIPC media information available to internal users
* @send_msg: routine which handles buffer transmission
- * @enable_bearer: routine which enables a bearer
- * @disable_bearer: routine which disables a bearer
+ * @enable_media: routine which enables a media
+ * @disable_media: routine which disables a media
* @addr2str: routine which converts media address to string
* @addr2msg: routine which converts media address to protocol message area
* @msg2addr: routine which converts media address from protocol message area
@@ -91,8 +91,8 @@ struct tipc_media {
int (*send_msg)(struct sk_buff *buf,
struct tipc_bearer *b_ptr,
struct tipc_media_addr *dest);
- int (*enable_bearer)(struct tipc_bearer *b_ptr);
- void (*disable_bearer)(struct tipc_bearer *b_ptr);
+ int (*enable_media)(struct tipc_bearer *b_ptr);
+ void (*disable_media)(struct tipc_bearer *b_ptr);
int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
int (*addr2msg)(struct tipc_media_addr *a, char *msg_area);
int (*msg2addr)(const struct tipc_bearer *b_ptr,
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index 40ea40c..e048d49 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -2,7 +2,7 @@
* net/tipc/eth_media.c: Ethernet bearer support for TIPC
*
* Copyright (c) 2001-2007, Ericsson AB
- * Copyright (c) 2005-2008, 2011, Wind River Systems
+ * Copyright (c) 2005-2008, 2011-2013, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,19 +37,19 @@
#include "core.h"
#include "bearer.h"
-#define MAX_ETH_BEARERS MAX_BEARERS
+#define MAX_ETH_MEDIA MAX_BEARERS
#define ETH_ADDR_OFFSET 4 /* message header offset of MAC address */
/**
- * struct eth_bearer - Ethernet bearer data structure
+ * struct eth_media - Ethernet bearer data structure
* @bearer: ptr to associated "generic" bearer structure
* @dev: ptr to associated Ethernet network device
* @tipc_packet_type: used in binding TIPC to Ethernet driver
* @setup: work item used when enabling bearer
* @cleanup: work item used when disabling bearer
*/
-struct eth_bearer {
+struct eth_media {
struct tipc_bearer *bearer;
struct net_device *dev;
struct packet_type tipc_packet_type;
@@ -58,7 +58,7 @@ struct eth_bearer {
};
static struct tipc_media eth_media_info;
-static struct eth_bearer eth_bearers[MAX_ETH_BEARERS];
+static struct eth_media eth_media_array[MAX_ETH_MEDIA];
static int eth_started;
static int recv_notification(struct notifier_block *nb, unsigned long evt,
@@ -100,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
if (!clone)
return 0;
- dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev;
+ dev = ((struct eth_media *)(tb_ptr->usr_handle))->dev;
delta = dev->hard_header_len - skb_headroom(buf);
if ((delta > 0) &&
@@ -128,7 +128,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
static int recv_msg(struct sk_buff *buf, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
- struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv;
+ struct eth_media *eb_ptr = (struct eth_media *)pt->af_packet_priv;
if (!net_eq(dev_net(dev), &init_net)) {
kfree_skb(buf);
@@ -147,24 +147,24 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
}
/**
- * setup_bearer - setup association between Ethernet bearer and interface
+ * setup_media - setup association between Ethernet bearer and interface
*/
-static void setup_bearer(struct work_struct *work)
+static void setup_media(struct work_struct *work)
{
- struct eth_bearer *eb_ptr =
- container_of(work, struct eth_bearer, setup);
+ struct eth_media *eb_ptr =
+ container_of(work, struct eth_media, setup);
dev_add_pack(&eb_ptr->tipc_packet_type);
}
/**
- * enable_bearer - attach TIPC bearer to an Ethernet interface
+ * enable_media - attach TIPC bearer to an Ethernet interface
*/
-static int enable_bearer(struct tipc_bearer *tb_ptr)
+static int enable_media(struct tipc_bearer *tb_ptr)
{
struct net_device *dev;
- struct eth_bearer *eb_ptr = ð_bearers[0];
- struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS];
+ struct eth_media *eb_ptr = ð_media_array[0];
+ struct eth_media *stop = ð_media_array[MAX_ETH_MEDIA];
char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
int pending_dev = 0;
@@ -188,7 +188,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
eb_ptr->tipc_packet_type.func = recv_msg;
eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr;
INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list));
- INIT_WORK(&eb_ptr->setup, setup_bearer);
+ INIT_WORK(&eb_ptr->setup, setup_media);
schedule_work(&eb_ptr->setup);
/* Associate TIPC bearer with Ethernet bearer */
@@ -205,14 +205,14 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
}
/**
- * cleanup_bearer - break association between Ethernet bearer and interface
+ * cleanup_media - break association between Ethernet bearer and interface
*
* This routine must be invoked from a work queue because it can sleep.
*/
-static void cleanup_bearer(struct work_struct *work)
+static void cleanup_media(struct work_struct *work)
{
- struct eth_bearer *eb_ptr =
- container_of(work, struct eth_bearer, cleanup);
+ struct eth_media *eb_ptr =
+ container_of(work, struct eth_media, cleanup);
dev_remove_pack(&eb_ptr->tipc_packet_type);
dev_put(eb_ptr->dev);
@@ -220,18 +220,18 @@ static void cleanup_bearer(struct work_struct *work)
}
/**
- * disable_bearer - detach TIPC bearer from an Ethernet interface
+ * disable_media - detach TIPC bearer from an Ethernet interface
*
* Mark Ethernet bearer as inactive so that incoming buffers are thrown away,
* then get worker thread to complete bearer cleanup. (Can't do cleanup
* here because cleanup code needs to sleep and caller holds spinlocks.)
*/
-static void disable_bearer(struct tipc_bearer *tb_ptr)
+static void disable_media(struct tipc_bearer *tb_ptr)
{
- struct eth_bearer *eb_ptr = (struct eth_bearer *)tb_ptr->usr_handle;
+ struct eth_media *eb_ptr = (struct eth_media *)tb_ptr->usr_handle;
eb_ptr->bearer = NULL;
- INIT_WORK(&eb_ptr->cleanup, cleanup_bearer);
+ INIT_WORK(&eb_ptr->cleanup, cleanup_media);
schedule_work(&eb_ptr->cleanup);
}
@@ -245,8 +245,8 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
- struct eth_bearer *eb_ptr = ð_bearers[0];
- struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS];
+ struct eth_media *eb_ptr = ð_media_array[0];
+ struct eth_media *stop = ð_media_array[MAX_ETH_MEDIA];
if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;
@@ -327,8 +327,8 @@ static int eth_msg2addr(const struct tipc_bearer *tb_ptr,
*/
static struct tipc_media eth_media_info = {
.send_msg = send_msg,
- .enable_bearer = enable_bearer,
- .disable_bearer = disable_bearer,
+ .enable_media = enable_media,
+ .disable_media = disable_media,
.addr2str = eth_addr2str,
.addr2msg = eth_addr2msg,
.msg2addr = eth_msg2addr,
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c
index 9934a32..5545145 100644
--- a/net/tipc/ib_media.c
+++ b/net/tipc/ib_media.c
@@ -42,17 +42,17 @@
#include "core.h"
#include "bearer.h"
-#define MAX_IB_BEARERS MAX_BEARERS
+#define MAX_IB_MEDIA MAX_BEARERS
/**
- * struct ib_bearer - Infiniband bearer data structure
+ * struct ib_media - Infiniband media data structure
* @bearer: ptr to associated "generic" bearer structure
* @dev: ptr to associated Infiniband network device
* @tipc_packet_type: used in binding TIPC to Infiniband driver
* @cleanup: work item used when disabling bearer
*/
-struct ib_bearer {
+struct ib_media {
struct tipc_bearer *bearer;
struct net_device *dev;
struct packet_type tipc_packet_type;
@@ -61,7 +61,7 @@ struct ib_bearer {
};
static struct tipc_media ib_media_info;
-static struct ib_bearer ib_bearers[MAX_IB_BEARERS];
+static struct ib_media ib_media_array[MAX_IB_MEDIA];
static int ib_started;
/**
@@ -93,7 +93,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
if (!clone)
return 0;
- dev = ((struct ib_bearer *)(tb_ptr->usr_handle))->dev;
+ dev = ((struct ib_media *)(tb_ptr->usr_handle))->dev;
delta = dev->hard_header_len - skb_headroom(buf);
if ((delta > 0) &&
@@ -121,7 +121,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
static int recv_msg(struct sk_buff *buf, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
- struct ib_bearer *ib_ptr = (struct ib_bearer *)pt->af_packet_priv;
+ struct ib_media *ib_ptr = (struct ib_media *)pt->af_packet_priv;
if (!net_eq(dev_net(dev), &init_net)) {
kfree_skb(buf);
@@ -142,22 +142,22 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
/**
* setup_bearer - setup association between InfiniBand bearer and interface
*/
-static void setup_bearer(struct work_struct *work)
+static void setup_media(struct work_struct *work)
{
- struct ib_bearer *ib_ptr =
- container_of(work, struct ib_bearer, setup);
+ struct ib_media *ib_ptr =
+ container_of(work, struct ib_media, setup);
dev_add_pack(&ib_ptr->tipc_packet_type);
}
/**
- * enable_bearer - attach TIPC bearer to an InfiniBand interface
+ * enable_media - attach TIPC bearer to an InfiniBand interface
*/
-static int enable_bearer(struct tipc_bearer *tb_ptr)
+static int enable_media(struct tipc_bearer *tb_ptr)
{
struct net_device *dev;
- struct ib_bearer *ib_ptr = &ib_bearers[0];
- struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS];
+ struct ib_media *ib_ptr = &ib_media_array[0];
+ struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA];
char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
int pending_dev = 0;
@@ -181,7 +181,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
ib_ptr->tipc_packet_type.func = recv_msg;
ib_ptr->tipc_packet_type.af_packet_priv = ib_ptr;
INIT_LIST_HEAD(&(ib_ptr->tipc_packet_type.list));
- INIT_WORK(&ib_ptr->setup, setup_bearer);
+ INIT_WORK(&ib_ptr->setup, setup_media);
schedule_work(&ib_ptr->setup);
/* Associate TIPC bearer with InfiniBand bearer */
@@ -204,8 +204,8 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
*/
static void cleanup_bearer(struct work_struct *work)
{
- struct ib_bearer *ib_ptr =
- container_of(work, struct ib_bearer, cleanup);
+ struct ib_media *ib_ptr =
+ container_of(work, struct ib_media, cleanup);
dev_remove_pack(&ib_ptr->tipc_packet_type);
dev_put(ib_ptr->dev);
@@ -213,15 +213,15 @@ static void cleanup_bearer(struct work_struct *work)
}
/**
- * disable_bearer - detach TIPC bearer from an InfiniBand interface
+ * disable_media - detach TIPC bearer from an InfiniBand interface
*
* Mark InfiniBand bearer as inactive so that incoming buffers are thrown away,
* then get worker thread to complete bearer cleanup. (Can't do cleanup
* here because cleanup code needs to sleep and caller holds spinlocks.)
*/
-static void disable_bearer(struct tipc_bearer *tb_ptr)
+static void disable_media(struct tipc_bearer *tb_ptr)
{
- struct ib_bearer *ib_ptr = (struct ib_bearer *)tb_ptr->usr_handle;
+ struct ib_media *ib_ptr = (struct ib_media *)tb_ptr->usr_handle;
ib_ptr->bearer = NULL;
INIT_WORK(&ib_ptr->cleanup, cleanup_bearer);
@@ -238,8 +238,8 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
- struct ib_bearer *ib_ptr = &ib_bearers[0];
- struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS];
+ struct ib_media *ib_ptr = &ib_media_array[0];
+ struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA];
if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;
@@ -323,8 +323,8 @@ static int ib_msg2addr(const struct tipc_bearer *tb_ptr,
*/
static struct tipc_media ib_media_info = {
.send_msg = send_msg,
- .enable_bearer = enable_bearer,
- .disable_bearer = disable_bearer,
+ .enable_media = enable_media,
+ .disable_media = disable_media,
.addr2str = ib_addr2str,
.addr2msg = ib_addr2msg,
.msg2addr = ib_msg2addr,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 3/5] tipc: avoid unnecessary lookup for tipc bearer instance
2013-09-24 9:27 [PATCH net-next 0/5] tipc: some small patches Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 1/5] tipc: silence sparse warnings Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 2/5] tipc: make bearer and media naming consistent Jon Maloy
@ 2013-09-24 9:27 ` Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 4/5] tipc: correct return value of recv_msg routine Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 5/5] tipc: correct return value of link_cmd_set_value routine Jon Maloy
4 siblings, 0 replies; 11+ messages in thread
From: Jon Maloy @ 2013-09-24 9:27 UTC (permalink / raw)
To: davem
Cc: netdev, Paul Gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, Jon Maloy
From: Ying Xue <ying.xue@windriver.com>
tipc_block_bearer() currently takes a bearer name (const char*)
as argument. This requires the function to make a lookup to find
the pointer to the corresponding bearer struct. In the current
code base this is not necessary, since the only two callers
(tipc_continue(),recv_notification()) already have validated
copies of this pointer, and hence can pass it directly in the
function call.
We change tipc_block_bearer() to directly take struct tipc_bearer*
as argument instead.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/bearer.c | 14 +++-----------
net/tipc/bearer.h | 2 +-
net/tipc/eth_media.c | 6 +++---
net/tipc/ib_media.c | 6 +++---
4 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 09faa55..3f9707a 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -420,23 +420,15 @@ exit:
}
/**
- * tipc_block_bearer - Block the bearer with the given name, and reset all its links
+ * tipc_block_bearer - Block the bearer, and reset all its links
*/
-int tipc_block_bearer(const char *name)
+int tipc_block_bearer(struct tipc_bearer *b_ptr)
{
- struct tipc_bearer *b_ptr = NULL;
struct tipc_link *l_ptr;
struct tipc_link *temp_l_ptr;
read_lock_bh(&tipc_net_lock);
- b_ptr = tipc_bearer_find(name);
- if (!b_ptr) {
- pr_warn("Attempt to block unknown bearer <%s>\n", name);
- read_unlock_bh(&tipc_net_lock);
- return -EINVAL;
- }
-
- pr_info("Blocking bearer <%s>\n", name);
+ pr_info("Blocking bearer <%s>\n", b_ptr->name);
spin_lock_bh(&b_ptr->lock);
b_ptr->blocked = 1;
list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index f800e63..e5e04be 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -163,7 +163,7 @@ int tipc_register_media(struct tipc_media *m_ptr);
void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
-int tipc_block_bearer(const char *name);
+int tipc_block_bearer(struct tipc_bearer *b_ptr);
void tipc_continue(struct tipc_bearer *tb_ptr);
int tipc_enable_bearer(const char *bearer_name, u32 disc_domain, u32 priority);
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index e048d49..c36c938 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -265,17 +265,17 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
if (netif_carrier_ok(dev))
tipc_continue(eb_ptr->bearer);
else
- tipc_block_bearer(eb_ptr->bearer->name);
+ tipc_block_bearer(eb_ptr->bearer);
break;
case NETDEV_UP:
tipc_continue(eb_ptr->bearer);
break;
case NETDEV_DOWN:
- tipc_block_bearer(eb_ptr->bearer->name);
+ tipc_block_bearer(eb_ptr->bearer);
break;
case NETDEV_CHANGEMTU:
case NETDEV_CHANGEADDR:
- tipc_block_bearer(eb_ptr->bearer->name);
+ tipc_block_bearer(eb_ptr->bearer);
tipc_continue(eb_ptr->bearer);
break;
case NETDEV_UNREGISTER:
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c
index 5545145..20b1aa4 100644
--- a/net/tipc/ib_media.c
+++ b/net/tipc/ib_media.c
@@ -258,17 +258,17 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
if (netif_carrier_ok(dev))
tipc_continue(ib_ptr->bearer);
else
- tipc_block_bearer(ib_ptr->bearer->name);
+ tipc_block_bearer(ib_ptr->bearer);
break;
case NETDEV_UP:
tipc_continue(ib_ptr->bearer);
break;
case NETDEV_DOWN:
- tipc_block_bearer(ib_ptr->bearer->name);
+ tipc_block_bearer(ib_ptr->bearer);
break;
case NETDEV_CHANGEMTU:
case NETDEV_CHANGEADDR:
- tipc_block_bearer(ib_ptr->bearer->name);
+ tipc_block_bearer(ib_ptr->bearer);
tipc_continue(ib_ptr->bearer);
break;
case NETDEV_UNREGISTER:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 4/5] tipc: correct return value of recv_msg routine
2013-09-24 9:27 [PATCH net-next 0/5] tipc: some small patches Jon Maloy
` (2 preceding siblings ...)
2013-09-24 9:27 ` [PATCH net-next 3/5] tipc: avoid unnecessary lookup for tipc bearer instance Jon Maloy
@ 2013-09-24 9:27 ` Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 5/5] tipc: correct return value of link_cmd_set_value routine Jon Maloy
4 siblings, 0 replies; 11+ messages in thread
From: Jon Maloy @ 2013-09-24 9:27 UTC (permalink / raw)
To: davem
Cc: netdev, Paul Gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, Jon Maloy
From: Ying Xue <ying.xue@windriver.com>
Currently, rcv_msg() always returns zero on a packet delivery upcall
from net_device.
To make its behavior more compliant with the way this API should be
used, we change this to let it return NET_RX_SUCCESS (which is zero
anyway) when it is able to handle the packet, and NET_RX_DROP otherwise.
The latter does not imply any functional change, it only enables the
driver to keep more accurate statistics about the fate of delivered
packets.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/eth_media.c | 6 +++---
net/tipc/ib_media.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index c36c938..f80d59f 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -132,18 +132,18 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
if (!net_eq(dev_net(dev), &init_net)) {
kfree_skb(buf);
- return 0;
+ return NET_RX_DROP;
}
if (likely(eb_ptr->bearer)) {
if (likely(buf->pkt_type <= PACKET_BROADCAST)) {
buf->next = NULL;
tipc_recv_msg(buf, eb_ptr->bearer);
- return 0;
+ return NET_RX_SUCCESS;
}
}
kfree_skb(buf);
- return 0;
+ return NET_RX_DROP;
}
/**
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c
index 20b1aa4..c139892 100644
--- a/net/tipc/ib_media.c
+++ b/net/tipc/ib_media.c
@@ -125,18 +125,18 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
if (!net_eq(dev_net(dev), &init_net)) {
kfree_skb(buf);
- return 0;
+ return NET_RX_DROP;
}
if (likely(ib_ptr->bearer)) {
if (likely(buf->pkt_type <= PACKET_BROADCAST)) {
buf->next = NULL;
tipc_recv_msg(buf, ib_ptr->bearer);
- return 0;
+ return NET_RX_SUCCESS;
}
}
kfree_skb(buf);
- return 0;
+ return NET_RX_DROP;
}
/**
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 5/5] tipc: correct return value of link_cmd_set_value routine
2013-09-24 9:27 [PATCH net-next 0/5] tipc: some small patches Jon Maloy
` (3 preceding siblings ...)
2013-09-24 9:27 ` [PATCH net-next 4/5] tipc: correct return value of recv_msg routine Jon Maloy
@ 2013-09-24 9:27 ` Jon Maloy
4 siblings, 0 replies; 11+ messages in thread
From: Jon Maloy @ 2013-09-24 9:27 UTC (permalink / raw)
To: davem
Cc: netdev, Paul Gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, Jon Maloy
From: Ying Xue <ying.xue@windriver.com>
link_cmd_set_value() takes commands for link, bearer and media related
configuration. Genereally the function returns 0 when a command is
recognized, and -EINVAL when it is not. However, in the switch for link
related commands it returns 0 even when the command is unrecognized. This
will sometimes make it look as if a failed configuration command has been
successful, but has otherwise no negative effects.
We remove this anomaly by returning -EINVAL even for link commands. We also
rework all three switches to make them conforming to common kernel coding
style.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/link.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 40521ae..8bbe4ca 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2647,6 +2647,7 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd)
struct tipc_link *l_ptr;
struct tipc_bearer *b_ptr;
struct tipc_media *m_ptr;
+ int res = 0;
l_ptr = link_find_link(name, &node);
if (l_ptr) {
@@ -2669,9 +2670,12 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd)
case TIPC_CMD_SET_LINK_WINDOW:
tipc_link_set_queue_limits(l_ptr, new_value);
break;
+ default:
+ res = -EINVAL;
+ break;
}
tipc_node_unlock(node);
- return 0;
+ return res;
}
b_ptr = tipc_bearer_find(name);
@@ -2679,15 +2683,18 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd)
switch (cmd) {
case TIPC_CMD_SET_LINK_TOL:
b_ptr->tolerance = new_value;
- return 0;
+ break;
case TIPC_CMD_SET_LINK_PRI:
b_ptr->priority = new_value;
- return 0;
+ break;
case TIPC_CMD_SET_LINK_WINDOW:
b_ptr->window = new_value;
- return 0;
+ break;
+ default:
+ res = -EINVAL;
+ break;
}
- return -EINVAL;
+ return res;
}
m_ptr = tipc_media_find(name);
@@ -2696,15 +2703,18 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd)
switch (cmd) {
case TIPC_CMD_SET_LINK_TOL:
m_ptr->tolerance = new_value;
- return 0;
+ break;
case TIPC_CMD_SET_LINK_PRI:
m_ptr->priority = new_value;
- return 0;
+ break;
case TIPC_CMD_SET_LINK_WINDOW:
m_ptr->window = new_value;
- return 0;
+ break;
+ default:
+ res = -EINVAL;
+ break;
}
- return -EINVAL;
+ return res;
}
struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/5] tipc: silence sparse warnings
2013-09-24 9:27 ` [PATCH net-next 1/5] tipc: silence sparse warnings Jon Maloy
@ 2013-09-27 5:59 ` David Miller
2013-09-27 8:01 ` Ying Xue
0 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2013-09-27 5:59 UTC (permalink / raw)
To: jon.maloy
Cc: netdev, paul.gortmaker, erik.hugne, ying.xue, maloy,
tipc-discussion, andreas.bofjall
From: Jon Maloy <jon.maloy@ericsson.com>
Date: Tue, 24 Sep 2013 04:27:44 -0500
> From: Ying Xue <ying.xue@windriver.com>
>
> Eliminate below sparse warnings:
>
> net/tipc/link.c:1210:37: warning: cast removes address space of expression
> net/tipc/link.c:1218:59: warning: incorrect type in argument 2 (different address spaces)
> net/tipc/link.c:1218:59: expected void const [noderef] <asn:1>*from
> net/tipc/link.c:1218:59: got unsigned char const [usertype] *[assigned] sect_crs
> net/tipc/msg.c:96:61: warning: incorrect type in argument 3 (different address spaces)
> net/tipc/msg.c:96:61: expected void const *from
> net/tipc/msg.c:96:61: got void [noderef] <asn:1>*const iov_base
> net/tipc/socket.c:341:49: warning: Using plain integer as NULL pointer
> net/tipc/socket.c:1371:36: warning: Using plain integer as NULL pointer
> net/tipc/socket.c:1694:57: warning: Using plain integer as NULL pointer
>
> Signed-off-by: Ying Xue <ying.xue@windriver.com>
> Signed-off-by: Andreas Bofjäll <andreas.bofjall@ericsson.com>
> Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
These warnings are not just for fun, and they are certainly not an
invitation to stick casts all over the place to make them go away.
They indicate real problems in the TIPC code.
There really are user pointers in the iovecs here, and that's why the
iov_base member is annotated with "__user".
These iovecs carry pointers that come from userspace via socket calls.
And you absolutely cannot pass user pointers to skb_copy_to_linear_data()
and friends as they access the source pointer using memcpy().
You have to use the proper interfaces for accessing userspace memory,
ones that have their arguments annotated with __user.
I'm not applying this series, sorry.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/5] tipc: silence sparse warnings
2013-09-27 5:59 ` David Miller
@ 2013-09-27 8:01 ` Ying Xue
2013-09-27 8:15 ` Andreas Bofjäll
0 siblings, 1 reply; 11+ messages in thread
From: Ying Xue @ 2013-09-27 8:01 UTC (permalink / raw)
To: David Miller
Cc: jon.maloy, netdev, paul.gortmaker, erik.hugne, maloy,
tipc-discussion, andreas.bofjall
On 09/27/2013 01:59 PM, David Miller wrote:
> From: Jon Maloy <jon.maloy@ericsson.com>
> Date: Tue, 24 Sep 2013 04:27:44 -0500
>
>> From: Ying Xue <ying.xue@windriver.com>
>>
>> Eliminate below sparse warnings:
>>
>> net/tipc/link.c:1210:37: warning: cast removes address space of expression
>> net/tipc/link.c:1218:59: warning: incorrect type in argument 2 (different address spaces)
>> net/tipc/link.c:1218:59: expected void const [noderef] <asn:1>*from
>> net/tipc/link.c:1218:59: got unsigned char const [usertype] *[assigned] sect_crs
>> net/tipc/msg.c:96:61: warning: incorrect type in argument 3 (different address spaces)
>> net/tipc/msg.c:96:61: expected void const *from
>> net/tipc/msg.c:96:61: got void [noderef] <asn:1>*const iov_base
>> net/tipc/socket.c:341:49: warning: Using plain integer as NULL pointer
>> net/tipc/socket.c:1371:36: warning: Using plain integer as NULL pointer
>> net/tipc/socket.c:1694:57: warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Ying Xue <ying.xue@windriver.com>
>> Signed-off-by: Andreas Bofjäll <andreas.bofjall@ericsson.com>
>> Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
>> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
>
> These warnings are not just for fun, and they are certainly not an
> invitation to stick casts all over the place to make them go away.
>
> They indicate real problems in the TIPC code.
>
> There really are user pointers in the iovecs here, and that's why the
> iov_base member is annotated with "__user".
>
> These iovecs carry pointers that come from userspace via socket calls.
>
> And you absolutely cannot pass user pointers to skb_copy_to_linear_data()
> and friends as they access the source pointer using memcpy().
>
Good point!
It's better for us to use memcpy_fromiovecend() instead of
skb_copy_to_linear_data() and its friends.
We will submit another version to correct this error soon.
Regards,
Ying
> You have to use the proper interfaces for accessing userspace memory,
> ones that have their arguments annotated with __user.
>
> I'm not applying this series, sorry.
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/5] tipc: silence sparse warnings
2013-09-27 8:01 ` Ying Xue
@ 2013-09-27 8:15 ` Andreas Bofjäll
2013-09-27 9:48 ` Ying Xue
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Bofjäll @ 2013-09-27 8:15 UTC (permalink / raw)
To: Ying Xue; +Cc: jon.maloy, netdev, tipc-discussion, David Miller
On 09/27/2013 10:01 AM, Ying Xue wrote:
> Good point!
> It's better for us to use memcpy_fromiovecend() instead of
> skb_copy_to_linear_data() and its friends.
>
> We will submit another version to correct this error soon.
I could be wrong here, but I think you should also remove the entire
cast on line 1210 in link.c:
sect_crs = msg_sect[curr_sect].iov_base;
There should be no reason to cast there since you made sect_crs into
const unchar* __user and msg_sect[].iov_base is void* __user.
/Andreas
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/5] tipc: silence sparse warnings
2013-09-27 8:15 ` Andreas Bofjäll
@ 2013-09-27 9:48 ` Ying Xue
2013-09-27 10:25 ` Jon Maloy
0 siblings, 1 reply; 11+ messages in thread
From: Ying Xue @ 2013-09-27 9:48 UTC (permalink / raw)
To: Andreas Bofjäll; +Cc: jon.maloy, netdev, tipc-discussion, David Miller
On 09/27/2013 04:15 PM, Andreas Bofjäll wrote:
> On 09/27/2013 10:01 AM, Ying Xue wrote:
>> Good point!
>> It's better for us to use memcpy_fromiovecend() instead of
>> skb_copy_to_linear_data() and its friends.
>>
>> We will submit another version to correct this error soon.
>
> I could be wrong here, but I think you should also remove the entire
> cast on line 1210 in link.c:
>
> sect_crs = msg_sect[curr_sect].iov_base;
>
> There should be no reason to cast there since you made sect_crs into
> const unchar* __user and msg_sect[].iov_base is void* __user.
>
You are right, thank you for your nice reminder!
Regards,
Ying
> /Andreas
>
>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/5] tipc: silence sparse warnings
2013-09-27 9:48 ` Ying Xue
@ 2013-09-27 10:25 ` Jon Maloy
0 siblings, 0 replies; 11+ messages in thread
From: Jon Maloy @ 2013-09-27 10:25 UTC (permalink / raw)
To: Ying Xue
Cc: Andreas Bofjäll, jon.maloy, netdev, paul.gortmaker,
erik.hugne, tipc-discussion
On 09/27/2013 05:48 AM, Ying Xue wrote:
> On 09/27/2013 04:15 PM, Andreas Bofjäll wrote:
>> On 09/27/2013 10:01 AM, Ying Xue wrote:
>>> Good point!
>>> It's better for us to use memcpy_fromiovecend() instead of
>>> skb_copy_to_linear_data() and its friends.
>>>
>>> We will submit another version to correct this error soon.
Can you fix this asap, so I can re-post it? And, let's continue the thread
in tipc-discussion only until we (incl Paul) are happy with this patch.
///jon
>> I could be wrong here, but I think you should also remove the entire
>> cast on line 1210 in link.c:
>>
>> sect_crs = msg_sect[curr_sect].iov_base;
>>
>> There should be no reason to cast there since you made sect_crs into
>> const unchar* __user and msg_sect[].iov_base is void* __user.
>>
> You are right, thank you for your nice reminder!
>
> Regards,
> Ying
>
>> /Andreas
>>
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-09-27 10:30 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-24 9:27 [PATCH net-next 0/5] tipc: some small patches Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 1/5] tipc: silence sparse warnings Jon Maloy
2013-09-27 5:59 ` David Miller
2013-09-27 8:01 ` Ying Xue
2013-09-27 8:15 ` Andreas Bofjäll
2013-09-27 9:48 ` Ying Xue
2013-09-27 10:25 ` Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 2/5] tipc: make bearer and media naming consistent Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 3/5] tipc: avoid unnecessary lookup for tipc bearer instance Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 4/5] tipc: correct return value of recv_msg routine Jon Maloy
2013-09-24 9:27 ` [PATCH net-next 5/5] tipc: correct return value of link_cmd_set_value routine Jon Maloy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).