From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:46506 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933301AbeBVRU0 (ORCPT ); Thu, 22 Feb 2018 12:20:26 -0500 Received: by mail-pl0-f67.google.com with SMTP id x19so3229531plr.13 for ; Thu, 22 Feb 2018 09:20:26 -0800 (PST) Subject: Re: [PATCH net-next v2 1/1] net: Allow a rule to track originating protocol To: Ido Schimmel , Donald Sharp Cc: netdev@vger.kernel.org References: <20180220135558.8469-2-sharpd@cumulusnetworks.com> <20180222082309.GA7140@splinter.mtl.com> From: David Ahern Message-ID: <75b4f864-763a-295e-3f8e-e791b10dfe9a@gmail.com> Date: Thu, 22 Feb 2018 10:20:22 -0700 MIME-Version: 1.0 In-Reply-To: <20180222082309.GA7140@splinter.mtl.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 2/22/18 1:23 AM, Ido Schimmel wrote: >> diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c >> index 98e1066c3d55..c1d4ab5b2d9f 100644 >> --- a/net/core/fib_rules.c >> +++ b/net/core/fib_rules.c >> @@ -51,6 +51,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops, >> r->pref = pref; >> r->table = table; >> r->flags = flags; >> + r->proto = RTPROT_KERNEL; >> r->fr_net = ops->fro_net; >> r->uid_range = fib_kuid_range_unset; >> >> @@ -465,6 +466,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, >> } >> refcount_set(&rule->refcnt, 1); >> rule->fr_net = net; >> + rule->proto = frh->proto; >> >> rule->pref = tb[FRA_PRIORITY] ? nla_get_u32(tb[FRA_PRIORITY]) >> : fib_default_rule_pref(ops); >> @@ -664,6 +666,9 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh, >> } >> >> list_for_each_entry(rule, &ops->rules_list, list) { >> + if (frh->proto && (frh->proto != rule->proto)) >> + continue; > > This breaks my scripts: > # ip -4 rule show > 0: from all lookup local > 32766: from all lookup main > 32767: from all lookup default > > # ip -4 rule del pref 0 > RTNETLINK answers: No such file or directory > > Using iproute 4.15 in Fedora 27: > # ip -V > ip utility, iproute2-ss180129 > > Problem is iproute sets protocol to RTPROT_BOOT while rules are > installed with RTPROT_KERNEL. > > Maybe add FRA_PROTOCOL? > > Thanks! ugh. Another iproute2 bug that the kernel has to deal with. iproute2 has been using rtm for the ancillary header for rules when it should have been fib_rule_hdr. That bug allowed someone to set the protocol field to RTPROT_BOOT which was complete nonsense for rules until Donald's recent patch. That means all FIB rules need to default to RTPROT_BOOT. I hate to inherit that for the l3mdev rule, but looking at the iproute2 code I don't see any options. Donald: send a patch that changes the protocol for kernel installed rules to RTPROT_BOOT.