提交 be85d4ad 编写于 作者: U Urs Thuermann 提交者: David S. Miller

[AF_PACKET]: Fix minor code duplication

Simplify some code by eliminating duplicate if-else clauses in
packet_do_bind().
Signed-off-by: NUrs Thuermann <urs@isnogud.escape.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 57ce45dd
...@@ -881,20 +881,14 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc ...@@ -881,20 +881,14 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
if (protocol == 0) if (protocol == 0)
goto out_unlock; goto out_unlock;
if (dev) { if (!dev || (dev->flags & IFF_UP)) {
if (dev->flags&IFF_UP) {
dev_add_pack(&po->prot_hook);
sock_hold(sk);
po->running = 1;
} else {
sk->sk_err = ENETDOWN;
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_error_report(sk);
}
} else {
dev_add_pack(&po->prot_hook); dev_add_pack(&po->prot_hook);
sock_hold(sk); sock_hold(sk);
po->running = 1; po->running = 1;
} else {
sk->sk_err = ENETDOWN;
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_error_report(sk);
} }
out_unlock: out_unlock:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册