Message ID | 20201123110748.27849-1-fe@dev.tdt.de |
---|---|
State | Rejected |
Headers | show |
Series | netifd: add possibility to switch off route config | expand |
On Mon, Nov 23, 2020 at 12:08 PM Florian Eckert <fe@dev.tdt.de> wrote: > > This change adds the new configuration option `disabled` for the route > section, which can be used to temporarily disable the section so that > the route is not set. The advantage is that I do not have to delete the > whole configuration to achieve this. > > config route > option disabled '1 > > Signed-off-by: Florian Eckert <fe@dev.tdt.de> > --- > .../patches/001-make-route-disable.patch | 29 +++++++++++++++++++ > 1 file changed, 29 insertions(+) > create mode 100644 package/network/config/netifd/patches/001-make-route-disable.patch Patch needs to be submitted as a patch on the netifd git repo not as a separate patch on the OpenWrt git repo > > diff --git a/package/network/config/netifd/patches/001-make-route-disable.patch b/package/network/config/netifd/patches/001-make-route-disable.patch > new file mode 100644 > index 0000000000..8184449e4e > --- /dev/null > +++ b/package/network/config/netifd/patches/001-make-route-disable.patch > @@ -0,0 +1,29 @@ > +--- a/interface-ip.c > ++++ b/interface-ip.c > +@@ -49,6 +49,7 @@ enum { > + ROUTE_ONLINK, > + ROUTE_TYPE, > + ROUTE_PROTO, > ++ ROUTE_DISABLED, > + __ROUTE_MAX > + }; > + > +@@ -65,6 +66,7 @@ static const struct blobmsg_policy route > + [ROUTE_ONLINK] = { .name = "onlink", .type = BLOBMSG_TYPE_BOOL }, > + [ROUTE_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING }, > + [ROUTE_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING }, > ++ [ROUTE_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL }, > + }; > + > + const struct uci_blob_param_list route_attr_list = { > +@@ -400,6 +402,10 @@ interface_ip_add_route(struct interface > + > + blobmsg_parse(route_attr, __ROUTE_MAX, tb, blobmsg_data(attr), blobmsg_data_len(attr)); > + > ++ if ((cur = tb[ROUTE_DISABLED]) != NULL && blobmsg_get_bool(cur)) { > ++ return; > ++ } Respect existing code style; no curly brackets around single line statements Hans > ++ > + if (!iface) { > + if ((cur = tb[ROUTE_INTERFACE]) == NULL) > + return; > -- > 2.20.1 >
diff --git a/package/network/config/netifd/patches/001-make-route-disable.patch b/package/network/config/netifd/patches/001-make-route-disable.patch new file mode 100644 index 0000000000..8184449e4e --- /dev/null +++ b/package/network/config/netifd/patches/001-make-route-disable.patch @@ -0,0 +1,29 @@ +--- a/interface-ip.c ++++ b/interface-ip.c +@@ -49,6 +49,7 @@ enum { + ROUTE_ONLINK, + ROUTE_TYPE, + ROUTE_PROTO, ++ ROUTE_DISABLED, + __ROUTE_MAX + }; + +@@ -65,6 +66,7 @@ static const struct blobmsg_policy route + [ROUTE_ONLINK] = { .name = "onlink", .type = BLOBMSG_TYPE_BOOL }, + [ROUTE_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING }, + [ROUTE_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING }, ++ [ROUTE_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL }, + }; + + const struct uci_blob_param_list route_attr_list = { +@@ -400,6 +402,10 @@ interface_ip_add_route(struct interface + + blobmsg_parse(route_attr, __ROUTE_MAX, tb, blobmsg_data(attr), blobmsg_data_len(attr)); + ++ if ((cur = tb[ROUTE_DISABLED]) != NULL && blobmsg_get_bool(cur)) { ++ return; ++ } ++ + if (!iface) { + if ((cur = tb[ROUTE_INTERFACE]) == NULL) + return;
This change adds the new configuration option `disabled` for the route section, which can be used to temporarily disable the section so that the route is not set. The advantage is that I do not have to delete the whole configuration to achieve this. config route option disabled '1 Signed-off-by: Florian Eckert <fe@dev.tdt.de> --- .../patches/001-make-route-disable.patch | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package/network/config/netifd/patches/001-make-route-disable.patch