summaryrefslogtreecommitdiffhomepage
path: root/device.c
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2016-02-12 22:04:00 +0200
committerDaniel Golle <daniel@makrotopia.org>2017-01-10 12:48:39 +0100
commitabf52371db75eb449f12209ca1b7ffaa9d2baa22 (patch)
treefcf53af6c81932f51b882616718e3eb28010450b /device.c
parent64a655d8ffa9f0cea1bbdd35cac6b3b99b865270 (diff)
netifd: Add sendredirects config support
Setting /proc/sys/net/ipv4/conf/*/send_redirects is useful if a single layer-2 domain is shared among routed subnets. Sending redirects will prevents traffic from taking unnessesary detours through a gateway in cases where direct connectivity on layer 2 exists. This is commonly the case if an existing LAN infratructure with dump switches is used to additionally carry routing protocols like OLSR which are supported only by some nodes on the network. It's important to note that the default value for send_redirects differs for interface types (it's enabled on physical ethernet interfaces, but disabled e.g. on VLANs) due to olsrd changing /proc/sys/net/ipv4/conf/default/send_redirects during boot, thus the default differs also depending e.g. on the way an on-board switch is integrated on specific boards (as eth0 exists before olsrd is started, eth0.1 gets created by netifd later on...) Having a way to explicitely enable or disable send_redirects is thus desireable also to unify the default behaviour among different, but seemingly similar devices supported. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'device.c')
-rw-r--r--device.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/device.c b/device.c
index 3c57a02..43881e5 100644
--- a/device.c
+++ b/device.c
@@ -58,6 +58,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_MULTICAST] = { .name ="multicast", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_LEARNING] = { .name ="learning", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_UNICAST_FLOOD] = { .name ="unicast_flood", .type = BLOBMSG_TYPE_BOOL },
+ [DEV_ATTR_SENDREDIRECTS] = { .name = "sendredirects", .type = BLOBMSG_TYPE_BOOL },
};
const struct uci_blob_param_list device_attr_list = {
@@ -225,6 +226,8 @@ device_merge_settings(struct device *dev, struct device_settings *n)
n->multicast_fast_leave = s->multicast_fast_leave;
n->learning = s->learning;
n->unicast_flood = s->unicast_flood;
+ n->sendredirects = s->flags & DEV_OPT_SENDREDIRECTS ?
+ s->sendredirects : os->sendredirects;
n->flags = s->flags | os->flags | os->valid_flags;
}
@@ -363,6 +366,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
s->flags |= DEV_OPT_UNICAST_FLOOD;
}
+ if ((cur = tb[DEV_ATTR_SENDREDIRECTS])) {
+ s->sendredirects = blobmsg_get_bool(cur);
+ s->flags |= DEV_OPT_SENDREDIRECTS;
+ }
+
device_set_disabled(dev, disabled);
}
@@ -1050,6 +1058,8 @@ device_dump_status(struct blob_buf *b, struct device *dev)
blobmsg_add_u8(b, "learning", st.learning);
if (st.flags & DEV_OPT_UNICAST_FLOOD)
blobmsg_add_u8(b, "unicast_flood", st.unicast_flood);
+ if (st.flags & DEV_OPT_SENDREDIRECTS)
+ blobmsg_add_u8(b, "sendredirects", st.sendredirects);
}
s = blobmsg_open_table(b, "statistics");