IPv6: metrics of default routes on different interfaces (Ethernetvs. wifi)

From: Jan KundrÃt
Date: Sun Aug 28 2011 - 11:12:49 EST


Dear LKML,
in the IPv4 world, the default routes on my wired interface have a
different metric than the WiFi ones:

velbloud ~ # ip r
default via 192.168.1.1 dev eth0 metric 3
default via 192.168.3.1 dev wlan0 metric 2004
127.0.0.0/8 via 127.0.0.1 dev lo
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.250
192.168.3.0/24 dev wlan0 proto kernel scope link src 192.168.3.250

I'm assuming here that the metrics of the default routes are somehow
derived from the "kind" of the underlying network interface, so that a
gigabit Ethernet is preferred over a 100Mbps one, which is preferred
over a 10Mbps one, etc. Please correct me if I'm wrong and the metrics
have a different origin, or if the wired-ethernet-preference it's just a
pure luck.

On the other hand, the IPv6 default routes, as auto-configured by kernel
with help from radvd running on my router both have the same metric:

velbloud ~ # ip -6 r
2a00:c500:215:23f5::/64 dev eth0 proto kernel metric 256 expires 86394sec
2a00:c500:515:2336::/64 dev wlan0 proto kernel metric 256 expires
86036sec
fe80::/64 dev eth0 proto kernel metric 256
fe80::/64 dev wlan0 proto kernel metric 256
ff00::/8 dev eth0 metric 256
ff00::/8 dev wlan0 metric 256
default via fe80::c63d:c7ff:fe90:d066 dev eth0 proto kernel metric
1024 expires 1799sec hoplimit 64
default via fe80::c83d:c7ff:fe90:d066 dev wlan0 proto kernel metric
1024 expires 1442sec hoplimit 64

(The router is the same box for both networks, and the radvd is
configured to advertise a high AdvRoutePreference on wired ethernet and
a medium one over wifi. This has no effect, which is -- I guess --
expected, as the preference shall affect only selection among routers on
the same interface.)

In this particular setup (e1000e and iwl3945 on an ancient Thinkpad T60
2007-FRG, kernel 2.6.39-gentoo-r2), the end result is general IPv4
traffic preferring wired gigabit Ethernet, with IPv6 data utilizing the
WiFi connection.

I've tried grepping my kernel sources, but wasn't able to find out the
place where the interface type is used in metric assignment. Could you
please point me to the right direction, so that I can come up with a
patch doing the same for IPv6? Or is this a flawed idea for some reason?

I'd appreciate a Cc on reply, as I'm not subscribed to this list. Or
just yell at me if that's wrong approach here.

Cheers,
Jan

--
Trojita, a fast e-mail client -- http://trojita.flaska.net/

Attachment: signature.asc
Description: OpenPGP digital signature