proto-shell: add proto property for skipping device config
authorFelix Fietkau <nbd@nbd.name>
Mon, 13 May 2024 13:58:27 +0000 (15:58 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 3 Jun 2024 08:49:43 +0000 (10:49 +0200)
This is useful for PPPoE, where settings like MTU should not be applied to
the lower device

Signed-off-by: Felix Fietkau <nbd@nbd.name>
interface.c
proto-shell.c
proto.h
scripts/netifd-proto.sh

index 43525593c30222e806fd7fc37866a9703d9b925c..641bcddcf031f4ae472fb45eb5c9261d58fc9eb4 100644 (file)
@@ -652,7 +652,8 @@ interface_claim_device(struct interface *iface)
        } else if (iface->device &&
                !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
                dev = device_get(iface->device, true);
-               interface_set_device_config(iface, dev);
+               if (!(iface->proto_handler->flags & PROTO_FLAG_NODEV_CONFIG))
+                       interface_set_device_config(iface, dev);
        } else {
                dev = iface->ext_dev.dev;
        }
index 53165312abcd1d42ab75ccb2f68cd23d5c0ad2bd..4039d9e690a25ee72946aff188b8c9671e39e886 100644 (file)
@@ -912,6 +912,10 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj)
        if (tmp && json_object_get_boolean(tmp))
                handler->proto.flags |= PROTO_FLAG_NODEV;
 
+       tmp = json_get_field(obj, "no-device-config", json_type_boolean);
+       if (tmp && json_object_get_boolean(tmp))
+               handler->proto.flags |= PROTO_FLAG_NODEV_CONFIG;
+
        tmp = json_get_field(obj, "no-proto-task", json_type_boolean);
        if (tmp && json_object_get_boolean(tmp))
                handler->proto.flags |= PROTO_FLAG_NO_TASK;
diff --git a/proto.h b/proto.h
index 26a54bd19d4458f08c24b848eb6c22d357e82a30..5f7649dc9c86f19c51725efeb5a124177afea66d 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -40,6 +40,7 @@ enum {
        PROTO_FLAG_LASTERROR = (1 << 5),
        PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN = (1 << 6),
        PROTO_FLAG_NO_TASK = (1 << 7),
+       PROTO_FLAG_NODEV_CONFIG = (1 << 8),
 };
 
 struct interface_proto_state {
index 87d337df07e9aa94b80ea53d050eadde791739d9..0785b9c1fce24c8aca4320b995cd6bd6fb9d42a7 100644 (file)
@@ -437,6 +437,7 @@ init_proto() {
                dump)
                        add_protocol() {
                                no_device=0
+                               no_device_config=0
                                no_proto_task=0
                                available=0
                                renew_handler=0
@@ -450,6 +451,7 @@ init_proto() {
                                eval "proto_$1_init_config"
                                json_close_array
                                json_add_boolean no-device "$no_device"
+                               json_add_boolean no-device-config "$no_device_config"
                                json_add_boolean no-proto-task "$no_proto_task"
                                json_add_boolean available "$available"
                                json_add_boolean renew-handler "$renew_handler"