Hey!

Thanks for the patch! It doesn't apply cleanly on either 5.3.0-1
(https://packages.debian.org/source/bullseye/iproute2) or 4.20.0
(https://packages.debian.org/source/buster/iproute2), so I applied it manually. 
It appears to give
me another error:

```
# ip route get 2.0.0.1 table local 
Error: ipv4: Invalid values in header for route get request.
# ip route get 2001::1 table local
Error: ipv6: Invalid values in header for get route request.
```

Cheers,

-- 
Clément 'wxcafé' Hertling

November 14, 2019 7:08 AM, "Luca Boccassi" <bl...@debian.org> wrote:

> On Thu, 14 Nov 2019 06:20:51 -0500 =?utf-
> 8?b?Q2zDqW1lbnQgJ3d4Y2Fmw6knIEhlcnRsaW5n?= <
> wxc...@wxcafe.net
> 
>> wrote:
>> Package: iproute2
>> Version: 5.3.0-1
>> Severity: normal
>> Tags: ipv6 upstream
>> 
>> `ip route get` is a great tool to lookup how the host will route to a
>> specific destination.
>> Unfortunately, while many other `ip route` subcommands can use `table
>> foo` to work with a specific routing table, `ip route get` can't:
>> 
>> ```
>> # ip route get 62.210.115.205
>> 62.210.115.205 via 10.242.10.13 dev tun0 src 10.242.10.14 uid 1000
>> cache
>> # ip route get 62.210.115.205 table local
>> Error: inet prefix is expected rather than "table".
>> ```
>> 
>> It'd be great to be able to use routing tables normally with ip route
>> get as with other iproute2 tools
>> 
>> Thank you
> 
> Could you please test the following simple patch:
> 
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -71,6 +71,7 @@ static void usage(void)
> " [ mark NUMBER ] [ vrf NAME ]\n"
> " [ uid NUMBER ] [ ipproto PROTOCOL ]\n"
> " [ sport NUMBER ] [ dport NUMBER ]\n"
> + " [ table TABLE_ID ]\n"
> " ip route { add | del | change | append | replace } ROUTE\n"
> "SELECTOR := [ root PREFIX ] [ match PREFIX ] [ exact PREFIX ]\n"
> " [ table TABLE_ID ] [ vrf NAME ] [ proto RTPROTO ]\n"
> @@ -2044,6 +2045,18 @@ static int iproute_get(int argc, char **argv)
> invarg("Invalid \"ipproto\" value\n",
> *argv);
> addattr8(&req.n, sizeof(req), RTA_IP_PROTO, ipproto);
> + } else if (matches(*argv, "table") == 0) {
> + __u32 tid;
> +
> + NEXT_ARG();
> + if (rtnl_rttable_a2n(&tid, *argv))
> + invarg("\"table\" value is invalid\n", *argv);
> + if (tid < 256)
> + req.r.rtm_table = tid;
> + else {
> + req.r.rtm_table = RT_TABLE_UNSPEC;
> + addattr32(&req.n, sizeof(req), RTA_TABLE, tid);
> + }
> } else {
> inet_prefix addr;
> 
> --
> Kind regards,
> Luca Boccassi

Reply via email to