提交 00f5e06c 编写于 作者: L Li Zefan 提交者: David S. Miller

[CONNECTOR]: clean up {,__}cn_rx_skb()

- __cn_rx_skb() does nothing but calls cn_call_callback(), it doesn't
check skb and msg sizes as the comment suggests, but cn_rx_skb() checks
those sizes.

- In cn_rx_skb() Local variable 'len' is not used. 'len' is probably
intended to be passed to skb_pull(), but here skb_pull() is not needed,
instead skb_free() is called.
Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 fd00eecc
...@@ -181,34 +181,15 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v ...@@ -181,34 +181,15 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v
return err; return err;
} }
/*
* Skb receive helper - checks skb and msg size and calls callback
* helper.
*/
static int __cn_rx_skb(struct sk_buff *skb, struct nlmsghdr *nlh)
{
u32 pid, uid, seq, group;
struct cn_msg *msg;
pid = NETLINK_CREDS(skb)->pid;
uid = NETLINK_CREDS(skb)->uid;
seq = nlh->nlmsg_seq;
group = NETLINK_CB((skb)).dst_group;
msg = NLMSG_DATA(nlh);
return cn_call_callback(msg, (void (*)(void *))kfree_skb, skb);
}
/* /*
* Main netlink receiving function. * Main netlink receiving function.
* *
* It checks skb and netlink header sizes and calls the skb receive * It checks skb, netlink header and msg sizes, and calls callback helper.
* helper with a shared skb.
*/ */
static void cn_rx_skb(struct sk_buff *__skb) static void cn_rx_skb(struct sk_buff *__skb)
{ {
struct cn_msg *msg;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
u32 len;
int err; int err;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -224,11 +205,8 @@ static void cn_rx_skb(struct sk_buff *__skb) ...@@ -224,11 +205,8 @@ static void cn_rx_skb(struct sk_buff *__skb)
return; return;
} }
len = NLMSG_ALIGN(nlh->nlmsg_len); msg = NLMSG_DATA(nlh);
if (len > skb->len) err = cn_call_callback(msg, (void (*)(void *))kfree_skb, skb);
len = skb->len;
err = __cn_rx_skb(skb, nlh);
if (err < 0) if (err < 0)
kfree_skb(skb); kfree_skb(skb);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册