summaryrefslogtreecommitdiff
path: root/interface.c
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2022-07-27 07:34:39 +0200
committerRafał Miłecki <rafal@milecki.pl>2022-08-11 17:07:58 +0200
commit87fbefd95043c24ccd3d5639a90721a5ed0b8267 (patch)
tree47913101bd3a679086844bb4c9faf36febf7d2e2 /interface.c
parent39ef9fe1388029c476db62889ef2ef5661613321 (diff)
downloadnetifd-87fbefd95043c24ccd3d5639a90721a5ed0b8267.tar.gz
interface: support "zone" config option
Many protocol handlers support "zone" option independently and they pass it in the "data". Then it's read e.g. by a firewall[34]. Add support for "zone" directly to the netifd so: 1. It works for all protocols 2. Handlers don't have to duplicate code Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/interface.c b/interface.c
index b3bb601..255ce84 100644
--- a/interface.c
+++ b/interface.c
@@ -34,6 +34,7 @@ enum {
IFACE_ATTR_IFNAME, /* Backward compatibility */
IFACE_ATTR_PROTO,
IFACE_ATTR_AUTO,
+ IFACE_ATTR_ZONE,
IFACE_ATTR_JAIL,
IFACE_ATTR_JAIL_DEVICE,
IFACE_ATTR_JAIL_IFNAME,
@@ -62,6 +63,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
[IFACE_ATTR_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_AUTO] = { .name = "auto", .type = BLOBMSG_TYPE_BOOL },
+ [IFACE_ATTR_ZONE] = { .name = "zone", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_JAIL] = { .name = "jail", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_JAIL_DEVICE] = { .name = "jail_device", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_JAIL_IFNAME] = { .name = "jail_ifname", .type = BLOBMSG_TYPE_STRING },
@@ -832,6 +834,10 @@ interface_alloc(const char *name, struct blob_attr *config, bool dynamic)
blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
blob_data(config), blob_len(config));
+ iface->zone = NULL;
+ if ((cur = tb[IFACE_ATTR_ZONE]))
+ iface->zone = strdup(blobmsg_get_string(cur));
+
if ((cur = tb[IFACE_ATTR_PROTO]))
proto_name = blobmsg_data(cur);