Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1463 - netifd disagrees with static route documentation #6429

Open
openwrt-bot opened this issue Mar 30, 2018 · 0 comments
Open

FS#1463 - netifd disagrees with static route documentation #6429

openwrt-bot opened this issue Mar 30, 2018 · 0 comments
Labels
core packages pull request/issue for core (in-tree) packages flyspray

Comments

@openwrt-bot
Copy link

nwf:

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.

@aparcar aparcar added the core packages pull request/issue for core (in-tree) packages label Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core packages pull request/issue for core (in-tree) packages flyspray
Projects
None yet
Development

No branches or pull requests

2 participants