Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / net / core / rtnetlink.c
index a9be2c1..1ad61a2 100644 (file)
@@ -1523,6 +1523,7 @@ static int do_setlink(const struct sk_buff *skb,
                        goto errout;
                }
                if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
+                       put_net(net);
                        err = -EPERM;
                        goto errout;
                }
@@ -2751,11 +2752,17 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
        if (!br_afspec)
                goto nla_put_failure;
 
-       if (nla_put_u16(skb, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF) ||
-           nla_put_u16(skb, IFLA_BRIDGE_MODE, mode)) {
+       if (nla_put_u16(skb, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF)) {
                nla_nest_cancel(skb, br_afspec);
                goto nla_put_failure;
        }
+
+       if (mode != BRIDGE_MODE_UNDEF) {
+               if (nla_put_u16(skb, IFLA_BRIDGE_MODE, mode)) {
+                       nla_nest_cancel(skb, br_afspec);
+                       goto nla_put_failure;
+               }
+       }
        nla_nest_end(skb, br_afspec);
 
        protinfo = nla_nest_start(skb, IFLA_PROTINFO | NLA_F_NESTED);