Skip to content
  • Thomas Haller's avatar
    ifcfg-rh: add support for routing rules as "ROUTING_RULE_#" keys · 4d468044
    Thomas Haller authored
    initscripts support rule-* and rule6-* files for that.
    
    Up until now, we ignored these files for the most part, except if
    a user configured such files, the profile could not contain any static
    routes (or specify a route-table setting). This also worked together
    with the dispatcher script "examples/dispatcher/10-ifcfg-rh-routes.sh".
    
    We cannot now start taking over that file format for rules. It might
    break existing setups, because we can never fully understand all rules as
    they are understood by iproute2. Also, if a user has a rule/rule6 file and
    uses NetworkManager successfully today, then clearly there is a script
    in place to make that work. We must not break that when adding rules
    support.
    
    Hence, store routing rules as numbered "ROUTING_RULE_#" and
    "ROUTING_RULE6_#" keys.
    
    Note that we use different keys for IPv4 and IPv6. The main reason is
    that the string format is mostly compatible with iproute2. That means,
    you can take the value and pass it to `ip rule add`.
    However, `ip rule add` only accepts IPv4 rules. For IPv6 rules, the user
    needs to call `ip -6 rule add`. If we would use the same key for IPv4
    and IPv6, then it would be hard to write a script to do this.
    Also, nm_ip_routing_rule_from_string() does take the address family as
    hint in this case. This makes
    
      ROUTING_RULE_1="pref 1"
      ROUTING_RULE6_1="pref 1"
    
    automatically determine that address families. Otherwise, such
    abbreviated forms would be not valid.
    4d468044