Skip to contentSkip to conversation

Question about reading the routing table with netlink

DISCUSSION Fernando Gont 2 participants 2 messages Sep 10, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Folks,

Short version of the question:
I'm trying to loop up a routing table entry with a socket(AF_NETLINK,SOCK_RAW,NETLINK_ROUTE).

Everything seems fine, except that I do not quite understand what's the effect of setting the RTA_SRC attribute type when doing that.

Empirically, it seems that if the RTA_SRC attribute is set and it contains an address that is assigned to the interface involved in the route, then such address is later returned in the reply as an RTA_SRC attribute.

Aside question, I was curious about the NETLINK_FIB_LOOKUP family (I guess it can be used for the same purpose?) -- but I wasn't able to get much information about it.

Any help will be welcome.

Thanks!

P.S.: Not sure if this is the right forum to ask this.. please direct me elsewhere if appropriate.

Best regards,

Signature · 3 lines
Fernando Gont
e-mail: [email protected] || [email protected]
PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1
#1 lore raw
Quoted 8 lines · Fernando Gont

Folks,

Short version of the question:
I'm trying to loop up a routing table entry with a socket(AF_NETLINK,SOCK_RAW,NETLINK_ROUTE).

Everything seems fine, except that I do not quite understand what's the effect of setting the RTA_SRC attribute type when doing that.

It sets the source address for the routing table lookup. This is important if e.g. rules are specified or if ipv6 subtrees are in use.

Quoted 4 lines

Empirically, it seems that if the RTA_SRC attribute is set and it contains an address that is assigned to the interface involved in the route, then such address is later returned in the reply as an RTA_SRC attribute.

Hm, I thought that RTA_SRC only has a semantic in the request and is moslty just copied over to the response.

Greetings,

Hannes