[FS#1463] netifd disagrees with static route documentation

LEDE Bugs lede-bugs at lists.infradead.org
Fri Mar 30 15:30:15 PDT 2018


A new Flyspray task has been opened.  Details are below. 

User who did this - Nathaniel Wesley Filardo (nwf) 

Attached to Project - OpenWrt/LEDE Project
Summary - netifd disagrees with static route documentation
Task Type - Bug Report
Category - Packages
Status - Unconfirmed
Assigned To - 
Operating System - All
Severity - Medium
Priority - Very Low
Reported Version - Trunk
Due in Version - Undecided
Due Date - Undecided
Details - https://openwrt.org/docs/guide-user/network/routes_configuration says, of the static route "gateway" configuration variable, "If omitted, the gateway from the parent interface is taken; if set to 0.0.0.0 no gateway will be specified for the route".  However, netifd HEAD does not distinguish all zeros from unset.  In particular, https://git.openwrt.org/?p=project/netifd.git;a=blob;f=interface-ip.c;h=1c84d4f8afed8bbe8af9fcc868fb1472b048019d;hb=HEAD#l343 is the only place where ROUTE_GATEWAY is decoded from a blob message and will leave route->nexthop all zeros if none is provided:


 343         if ((cur = tb[ROUTE_GATEWAY]) != NULL) {
 344                 if (!inet_pton(af, blobmsg_data(cur), &route->nexthop)) {
 345                         DPRINTF("Failed to parse route gateway: %s\n", (char *) blobmsg_data(cur));
 346                         goto error;
 347                 }
 348         }


When it comes time to actually use the resulting route->nexthop value, https://git.openwrt.org/?p=project/netifd.git;a=blob;f=system-linux.c;h=0ca525602d9ea63ac5b845b2be9c6c7bdec7c26c;hb=HEAD#l1851 just checks for all-zeros and, if so, declares it to be a link-local route:


1851         if (alen == 4)
1852                 have_gw = !!route->nexthop.in.s_addr;
1853         else
1854                 have_gw = route->nexthop.in6.s6_addr32[0] ||
1855                         route->nexthop.in6.s6_addr32[1] ||
1856                         route->nexthop.in6.s6_addr32[2] ||
1857                         route->nexthop.in6.s6_addr32[3];
...
1882                         rtm.rtm_scope = (have_gw) ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK;
...
1925         if (have_gw)
1926                 nla_put(msg, RTA_GATEWAY, alen, &route->nexthop);


I believe that struct device_route needs a flag to indicate whether the incoming blobmsg had a ROUTE_GATEWAY or not, and that system_rt should use the device's configured default gateway if not.  There is, at present, no workaround except to hard-code the next hop in the configuration, which is gross.

More information can be found at the following URL:
https://bugs.openwrt.org/index.php?do=details&task_id=1463



More information about the lede-bugs mailing list