commit 65acc1ab450b8a0ccc3dd01cb8278dac3ac15fa0 from: Stefan Sperling date: Tue Sep 03 10:12:40 2024 UTC fix adding blackhole and reject routes; a gateway is required Fixes an invalid route message error during nsh -i at boot time: % cmd: route (line 49) margv [route 224.0.0.0/4 127.0.0.1 iface nompath reject] % RTM_ADD: Add Route: len 128, table 0, pid: 0, seq 1, errno 0, flags: % locks: inits: % sockaddrs: 224.0.0.0 240.0.0.0 % ip_route: rtmsg: Invalid argument test + ok Tom commit - 1ecf319919277305fea3d35396c316fc23e7f3db commit + 65acc1ab450b8a0ccc3dd01cb8278dac3ac15fa0 blob - e589a9248c616b92452683464991fe98de5758ca blob + a558cf19abc8bd22c365719553f577e6a42ebe5b --- route.c +++ route.c @@ -220,6 +220,14 @@ route(int argc, char **argv) printf("%% unknown destination address family %d\n", dest.family); return(1); } + + /* + * Adding blackhole or reject routes requires a gateway even if the + * "iface" parameter was specified. A gateway argument is required when + * adding routes so simply setting the GATEWAY flag here is sufficient. + */ + if (cmd == RTM_ADD && (flags & (RTF_BLACKHOLE|RTF_REJECT))) + flags |= RTF_GATEWAY; flags |= RTF_UP;