projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
interface-ip: Fix broadcast address when using /31 or /32 IPv4 addressing
[project/netifd.git]
/
interface-ip.c
diff --git
a/interface-ip.c
b/interface-ip.c
index
43b63c7
..
54f56d6
100644
(file)
--- a/
interface-ip.c
+++ b/
interface-ip.c
@@
-473,11
+473,17
@@
interface_update_proto_addr(struct vlist_tree *tree,
if ((a_new->flags & DEVADDR_FAMILY) == DEVADDR_INET4 &&
!a_new->broadcast) {
if ((a_new->flags & DEVADDR_FAMILY) == DEVADDR_INET4 &&
!a_new->broadcast) {
- uint32_t mask = ~0;
- uint32_t *a = (uint32_t *) &a_new->addr;
-
- mask >>= a_new->mask;
- a_new->broadcast = *a | htonl(mask);
+ /* /31 and /32 addressing need 255.255.255.255
+ * as broadcast address. */
+ if (a_new->mask >= 31) {
+ a_new->broadcast = (uint32_t) ~0;
+ } else {
+ uint32_t mask = ~0;
+ uint32_t *a = (uint32_t *) &a_new->addr;
+
+ mask >>= a_new->mask;
+ a_new->broadcast = *a | htonl(mask);
+ }
}
}
}
}
@@
-513,8
+519,10
@@
interface_update_proto_addr(struct vlist_tree *tree,
if (table) {
set_ip_source_policy(false, v6, IPRULE_PRIORITY_ADDR, &a_old->addr,
(v6) ? 128 : 32, table, NULL, NULL);
if (table) {
set_ip_source_policy(false, v6, IPRULE_PRIORITY_ADDR, &a_old->addr,
(v6) ? 128 : 32, table, NULL, NULL);
- set_ip_source_policy(false, v6, IPRULE_PRIORITY_NW, &a_old->addr,
- a_old->mask, table, NULL, NULL);
+
+ if (a_old->mask != ((v6) ? 128 : 32))
+ set_ip_source_policy(false, v6, IPRULE_PRIORITY_NW, &a_old->addr,
+ a_old->mask, table, NULL, NULL);
}
if (!(a_old->flags & DEVADDR_EXTERNAL)) {
}
if (!(a_old->flags & DEVADDR_EXTERNAL)) {
@@
-546,8
+554,10
@@
interface_update_proto_addr(struct vlist_tree *tree,
if (table) {
set_ip_source_policy(true, v6, IPRULE_PRIORITY_ADDR, &a_new->addr,
(v6) ? 128 : 32, table, NULL, NULL);
if (table) {
set_ip_source_policy(true, v6, IPRULE_PRIORITY_ADDR, &a_new->addr,
(v6) ? 128 : 32, table, NULL, NULL);
- set_ip_source_policy(true, v6, IPRULE_PRIORITY_NW, &a_new->addr,
- a_new->mask, table, NULL, NULL);
+
+ if (a_new->mask != ((v6) ? 128 : 32))
+ set_ip_source_policy(true, v6, IPRULE_PRIORITY_NW, &a_new->addr,
+ a_new->mask, table, NULL, NULL);
}
}
}
}
}
}
@@
-587,7
+597,7
@@
interface_update_proto_route(struct vlist_tree *tree,
if (node_old && node_new)
keep = !memcmp(&route_old->nexthop, &route_new->nexthop, sizeof(route_old->nexthop)) &&
(route_old->mtu == route_new->mtu) && (route_old->type == route_new->type) &&
if (node_old && node_new)
keep = !memcmp(&route_old->nexthop, &route_new->nexthop, sizeof(route_old->nexthop)) &&
(route_old->mtu == route_new->mtu) && (route_old->type == route_new->type) &&
-
(route_old->valid_until == route_new->valid_until) &&
!route_old->failed;
+ !route_old->failed;
if (node_old) {
if (!(route_old->flags & DEVADDR_EXTERNAL) && route_old->enabled && !keep)
if (node_old) {
if (!(route_old->flags & DEVADDR_EXTERNAL) && route_old->enabled && !keep)
@@
-1230,6
+1240,15
@@
void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled)
if (!(route->flags & DEVROUTE_METRIC))
route->metric = ip->iface->metric;
if (!(route->flags & DEVROUTE_METRIC))
route->metric = ip->iface->metric;
+ if (!(route->flags & DEVROUTE_TABLE)) {
+ route->flags &= ~DEVROUTE_SRCTABLE;
+ route->table = ((route->flags & DEVADDR_FAMILY) == DEVADDR_INET6) ?
+ iface->ip6table : iface->ip4table;
+
+ if (route->table)
+ route->flags |= DEVROUTE_SRCTABLE;
+ }
+
if (system_add_route(dev, route))
route->failed = true;
} else
if (system_add_route(dev, route))
route->failed = true;
} else