Skip to content

Commit 5adef18

Browse files
kaberdavem330
authored andcommitted
net 04/05: fib_rules: allow to delete local rule
commit d124356ce314fff22a047ea334379d5105b2d834 Author: Patrick McHardy <[email protected]> Date: Thu Dec 3 12:16:35 2009 +0100 net: fib_rules: allow to delete local rule Allow to delete the local rule and recreate it with a higher priority. This can be used to force packets with a local destination out on the wire instead of routing them to loopback. Additionally this patch allows to recreate rules with a priority of 0. Combined with the previous patch to allow oif classification, a socket can be bound to the desired interface and packets routed to the wire like this: # move local rule to lower priority ip rule add pref 1000 lookup local ip rule del pref 0 # route packets of sockets bound to eth0 to the wire independant # of the destination address ip rule add pref 100 oif eth0 lookup 100 ip route add default dev eth0 table 100 Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1b038a5 commit 5adef18

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

net/core/fib_rules.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
287287
rule->flags = frh->flags;
288288
rule->table = frh_get_table(frh, tb);
289289

290-
if (!rule->pref && ops->default_pref)
290+
if (!tb[FRA_PRIORITY] && ops->default_pref)
291291
rule->pref = ops->default_pref(ops);
292292

293293
err = -EINVAL;

net/ipv4/fib_rules.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int fib_default_rules_init(struct fib_rules_ops *ops)
284284
{
285285
int err;
286286

287-
err = fib_default_rule_add(ops, 0, RT_TABLE_LOCAL, FIB_RULE_PERMANENT);
287+
err = fib_default_rule_add(ops, 0, RT_TABLE_LOCAL, 0);
288288
if (err < 0)
289289
return err;
290290
err = fib_default_rule_add(ops, 0x7FFE, RT_TABLE_MAIN, 0);

net/ipv6/fib6_rules.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int fib6_rules_net_init(struct net *net)
276276
INIT_LIST_HEAD(&net->ipv6.fib6_rules_ops->rules_list);
277277

278278
err = fib_default_rule_add(net->ipv6.fib6_rules_ops, 0,
279-
RT6_TABLE_LOCAL, FIB_RULE_PERMANENT);
279+
RT6_TABLE_LOCAL, 0);
280280
if (err)
281281
goto out_fib6_rules_ops;
282282

0 commit comments

Comments
 (0)