Skip to content

Commit

Permalink
[NET] fib_rules: Mark rules detached from the device
Browse files Browse the repository at this point in the history
Rules which match against device names in their selector can
remain while the device itself disappears, in fact the device
doesn't have to present when the rule is added in the first
place. The device name is resolved by trying when the rule is
added and later by listening to NETDEV_REGISTER/UNREGISTER
notifications.

This patch adds the flag FIB_RULE_DEV_DETACHED which is set
towards userspace when a rule contains a device match which
is unresolved at the moment. This eases spotting the reason
why certain rules seem not to function properly.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thomas Graf authored and David S. Miller committed Apr 26, 2007
1 parent 0947c9f commit 2b44368
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/linux/fib_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define FIB_RULE_PERMANENT 1
#define FIB_RULE_INVERT 2
#define FIB_RULE_UNRESOLVED 4
#define FIB_RULE_DEV_DETACHED 8

struct fib_rule_hdr
{
Expand Down
6 changes: 5 additions & 1 deletion net/core/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,13 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
if (rule->action == FR_ACT_GOTO && rule->ctarget == NULL)
frh->flags |= FIB_RULE_UNRESOLVED;

if (rule->ifname[0])
if (rule->ifname[0]) {
NLA_PUT_STRING(skb, FRA_IFNAME, rule->ifname);

if (rule->ifindex == -1)
frh->flags |= FIB_RULE_DEV_DETACHED;
}

if (rule->pref)
NLA_PUT_U32(skb, FRA_PRIORITY, rule->pref);

Expand Down

0 comments on commit 2b44368

Please sign in to comment.