Bug 498472

Summary: Setting kernel route metric
Product: [Fedora] Fedora Reporter: Patrick Monnerat <patrick>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: iarlyy, initscripts-maint-list, kvolny, maurizio.antillon, notting, rvokal
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 554402 (view as bug list) Environment:
Last Closed: 2012-08-16 22:09:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 516998, 554402    
Attachments:
Description Flags
Patch to set interface route metric none

Description Patrick Monnerat 2009-04-30 16:25:02 UTC
Created attachment 341954 [details]
Patch to set interface route metric

Description of problem:
Interface routes added by the kernel always have metric 0. I need to change some of these metrics to establish a priority between interfaces accessing the same subnet (I do not want bonded interfaces: i need different and disjoint IPs).
An old report (bug #124045) seems to deal with the same problem and proposes a patch for an old initscripts version, but I cannot find tracks of the fix in any of the official releases, neither can I find a discussion explaining why it has not been implemented or why it has been withdrawn.


Version-Release number of selected component (if applicable):
initscripts-8.86.3-1.fc10

I've designed a patch introducing the configuration variable IF_METRIC to set kernel route metric for the interface. Since metrics cannot be changed easily, I implemented this as a function in network-functions, in case it is needed in another script.

Thanks for your attention

Comment 1 Bill Nottingham 2009-04-30 17:08:26 UTC
The old report refers to metric  on the gateway route, not the network route.

The contortions your patch goes through implies to me there should be a better way to set this.

Comment 2 Patrick Monnerat 2009-05-04 10:52:08 UTC
The "contorsions" are needed for the following reasons:
_ Kernel always sets an interface route with metric 0. No way to configure that.
_ Metric is part of the route "index": you cannot change the metric of a route, you only can build another route, cloned from the kernel one, but with another metric.
_ Since it has been made available to all scripts, the set_kernel_metric() function has been designed to be very general. In particular, it does not assume the original route metric is 0, in case someone needs to change the metric more than once for the same interface route.

    [ -z "$3" ] && return 0

If no metric is given, no change.

    if_route=`ip route list exact "$1" dev "$2" proto kernel`

Gets the full configured kernel route into `if_route'.

    [ -z "$if_route" ] && return 1

If no such route, error.

    if_metric=`echo "$if_route" |
      sed -e '/metric /!d' -e 's/^.*metric \([0-9]*\).*$/\1/'`

Gets the current metric from the route.

    if_metric=${if_metric:-0}

Makes sure it is numeric, even in the case metric was not mentioned (implicit 0).

    [ "$3" -eq $if_metric ] && return 0

If there is no metric change, we're done.

    if_route=`echo "$if_route dev $2 proto kernel" | sed 's/metric [0-9]*//'`

Modifies the route to force "proto kernel" and include the device, but not the metric.

    ip route add $if_route metric "$3" || return 1

Adds the same route with the new metric, exit if error.

    ip route del $if_route metric $if_metric

Deletes the original route. Exit with this command's status.


If you could find some shorter way to obtain the same result, I'll take it :-) But I really need this feature: it allows to control local routing by simple calls to ifup/ifdown. These calls can be automatically handled by ifplugd (for example). Since this is LOCAL routing, this feature cannot be handled by some dynamic routing manager (i.e.: quagga).

Comment 3 Bug Zapper 2009-11-18 11:53:05 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Patrick Monnerat 2009-11-30 16:15:34 UTC
Reassigning to F12: the feature has not yet been made available.

Comment 7 Patrick Monnerat 2010-01-12 17:50:15 UTC
Although this feature has been rejected for inclusion in RHEL6, I really need it in Fedora: it allows me to implement a pair of "poor man's redundant routers" with the help of MAC address alteration, arp_filter=1 and ifplugd.
There is one router active at a time, the other is considered as backup and works like a normal LAN-connected machine.
Each router has a dedicated permanent LAN connection for its private use. The active router is also connected to the routing points (LAN-gateway, DMZ and Internet).
Switching the routers simply consists in unpluging the LAN gateway, DMZ and Internet connections from the active router and replugging them to the backup router. The internal routing of both machines automatically changes accordingly.

This configuration works perfectly well for about 9 months here (with an average of 1 router switch per week) and would not be easily feasible without the kernel metric change feature.

Quagga is not an appropriate solution since it consumes too many IPs and alters external routes only.

Until now, I report my patch within each release of initscripts to support this feature.

Many thanks for reading and for reconsidering the implementation of this feature. I'll be glad to give you more info on my config if you need so.

Comment 10 Bug Zapper 2010-11-04 11:17:49 UTC
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 11 Patrick Monnerat 2010-11-05 11:21:09 UTC
Reassigning to F14: feature not yet available.

Comment 12 Fedora End Of Life 2012-08-16 22:09:26 UTC
This message is a notice that Fedora 14 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 14. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained.  At this time, all open bugs with a Fedora 'version'
of '14' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this 
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen 
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we were unable to fix it before Fedora 14 reached end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" (top right of this page) and open it against that 
version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping