提交 a8f74b22 编写于 作者: T Thomas Graf 提交者: Thomas Graf

[NETLINK]: Make netlink_callback->done() optional

Most netlink families make no use of the done() callback, making
it optional gets rid of all unnecessary dummy implementations.
Signed-off-by: NThomas Graf <tgraf@suug.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 bfa83a9e
...@@ -462,11 +462,6 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) ...@@ -462,11 +462,6 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
netlink_broadcast(rtnl, skb, 0, RTNLGRP_LINK, GFP_KERNEL); netlink_broadcast(rtnl, skb, 0, RTNLGRP_LINK, GFP_KERNEL);
} }
static int rtnetlink_done(struct netlink_callback *cb)
{
return 0;
}
/* Protected by RTNL sempahore. */ /* Protected by RTNL sempahore. */
static struct rtattr **rta_buf; static struct rtattr **rta_buf;
static int rtattr_max; static int rtattr_max;
...@@ -533,8 +528,7 @@ rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) ...@@ -533,8 +528,7 @@ rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
goto err_inval; goto err_inval;
if ((*errp = netlink_dump_start(rtnl, skb, nlh, if ((*errp = netlink_dump_start(rtnl, skb, nlh,
link->dumpit, link->dumpit, NULL)) != 0) {
rtnetlink_done)) != 0) {
return -1; return -1;
} }
rlen = NLMSG_ALIGN(nlh->nlmsg_len); rlen = NLMSG_ALIGN(nlh->nlmsg_len);
......
...@@ -724,12 +724,6 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -724,12 +724,6 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
return skb->len; return skb->len;
} }
static int inet_diag_dump_done(struct netlink_callback *cb)
{
return 0;
}
static __inline__ int static __inline__ int
inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
...@@ -760,8 +754,7 @@ inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -760,8 +754,7 @@ inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
goto err_inval; goto err_inval;
} }
return netlink_dump_start(idiagnl, skb, nlh, return netlink_dump_start(idiagnl, skb, nlh,
inet_diag_dump, inet_diag_dump, NULL);
inet_diag_dump_done);
} else { } else {
return inet_diag_get_exact(skb, nlh); return inet_diag_get_exact(skb, nlh);
} }
......
...@@ -1710,7 +1710,7 @@ static void fib6_dump_end(struct netlink_callback *cb) ...@@ -1710,7 +1710,7 @@ static void fib6_dump_end(struct netlink_callback *cb)
static int fib6_dump_done(struct netlink_callback *cb) static int fib6_dump_done(struct netlink_callback *cb)
{ {
fib6_dump_end(cb); fib6_dump_end(cb);
return cb->done(cb); return cb->done ? cb->done(cb) : 0;
} }
int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
......
...@@ -427,7 +427,8 @@ static int netlink_release(struct socket *sock) ...@@ -427,7 +427,8 @@ static int netlink_release(struct socket *sock)
spin_lock(&nlk->cb_lock); spin_lock(&nlk->cb_lock);
if (nlk->cb) { if (nlk->cb) {
nlk->cb->done(nlk->cb); if (nlk->cb->done)
nlk->cb->done(nlk->cb);
netlink_destroy_callback(nlk->cb); netlink_destroy_callback(nlk->cb);
nlk->cb = NULL; nlk->cb = NULL;
} }
...@@ -1322,7 +1323,8 @@ static int netlink_dump(struct sock *sk) ...@@ -1322,7 +1323,8 @@ static int netlink_dump(struct sock *sk)
skb_queue_tail(&sk->sk_receive_queue, skb); skb_queue_tail(&sk->sk_receive_queue, skb);
sk->sk_data_ready(sk, skb->len); sk->sk_data_ready(sk, skb->len);
cb->done(cb); if (cb->done)
cb->done(cb);
nlk->cb = NULL; nlk->cb = NULL;
spin_unlock(&nlk->cb_lock); spin_unlock(&nlk->cb_lock);
......
...@@ -948,11 +948,6 @@ static struct xfrm_link { ...@@ -948,11 +948,6 @@ static struct xfrm_link {
[XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_flush_policy }, [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_flush_policy },
}; };
static int xfrm_done(struct netlink_callback *cb)
{
return 0;
}
static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
{ {
struct rtattr *xfrma[XFRMA_MAX]; struct rtattr *xfrma[XFRMA_MAX];
...@@ -990,8 +985,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *err ...@@ -990,8 +985,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *err
goto err_einval; goto err_einval;
if ((*errp = netlink_dump_start(xfrm_nl, skb, nlh, if ((*errp = netlink_dump_start(xfrm_nl, skb, nlh,
link->dump, link->dump, NULL)) != 0) {
xfrm_done)) != 0) {
return -1; return -1;
} }
rlen = NLMSG_ALIGN(nlh->nlmsg_len); rlen = NLMSG_ALIGN(nlh->nlmsg_len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册