proto-shell: allow proto setups without ifname (if interface main dev is present)
authorFelix Fietkau <nbd@openwrt.org>
Thu, 13 Oct 2011 22:09:16 +0000 (00:09 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 13 Oct 2011 22:10:49 +0000 (00:10 +0200)
dummy/netifd-proto.sh
proto-shell.c

index 6182ce1471b938415b5dd92e0cfceedf9d8bcf18..0af99b2dbcb6e5ff91f379e596ba7853abb8f525 100755 (executable)
@@ -48,7 +48,7 @@ proto_init_update() {
        PROTO_ROUTE6=
        json_init
        json_add_int action 0
-       json_add_string "ifname" "$ifname"
+       [ -n "$ifname" -a "*" != "$ifname" ] && json_add_string "ifname" "$ifname"
        json_add_boolean "link-up" "$up"
        [ -n "$3" ] && json_add_boolean "address-external" "$external"
 }
index fdb87df4e5bc939cda34062706ca09ed2c2f9838..f5a5fb14b88e1c861ec58b72b52b9a773b6bc02e 100644 (file)
@@ -351,10 +351,10 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr **tb)
                return 0;
        }
 
-       if (!tb[NOTIFY_IFNAME])
-               return UBUS_STATUS_INVALID_ARGUMENT;
-
-       if (!state->l3_dev.dev) {
+       if (!tb[NOTIFY_IFNAME]) {
+               if (!state->iface->main_dev.dev)
+                       return UBUS_STATUS_INVALID_ARGUMENT;
+       } else if (!state->l3_dev.dev) {
                device_add_user(&state->l3_dev,
                        device_get(blobmsg_data(tb[NOTIFY_IFNAME]), true));
                device_claim(&state->l3_dev);