From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f43.google.com ([209.85.160.43]:38203 "EHLO mail-pl0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbeBURDb (ORCPT ); Wed, 21 Feb 2018 12:03:31 -0500 Received: by mail-pl0-f43.google.com with SMTP id d4so1241097pll.5 for ; Wed, 21 Feb 2018 09:03:31 -0800 (PST) Subject: Re: [PATCH iproute2-next 1/4] ip: Use the `struct fib_rule_hdr` for rules To: Donald Sharp , netdev@vger.kernel.org, dsahern@gmail.com References: <20180221015348.32646-2-sharpd@cumulusnetworks.com> From: David Ahern Message-ID: Date: Wed, 21 Feb 2018 10:04:00 -0700 MIME-Version: 1.0 In-Reply-To: <20180221015348.32646-2-sharpd@cumulusnetworks.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/20/18 6:53 PM, Donald Sharp wrote: > @@ -159,7 +159,13 @@ static bool filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len) > return false; > } > > - table = rtm_get_table(r, tb); > + > + /* struct fib_rule_hdr and struct rtmsg > + * were intentionally the same. Since > + * the table is the rtm_table, just call > + * it. > + */ > + table = rtm_get_table((struct rtmsg *)frh, tb); > if (filter.tb > 0 && filter.tb ^ table) > return false; > ... > @@ -273,7 +279,12 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) > fprintf(fp, "uidrange %u-%u ", r->start, r->end); > } > > - table = rtm_get_table(r, tb); > + /* struct fib_rule_hdr and struct rtmsg > + * were intentionally the same. Since > + * the table is the rtm_table, just call > + * it. > + */ > + table = rtm_get_table((struct rtmsg *)frh, tb); > if (table) { > fprintf(fp, "lookup %s ", > rtnl_rttable_n2a(table, b1, sizeof(b1))); I would rather have a second get_table function than use the typecast; frh_get_table() that mirrors rtm_get_table. Thanks for taking the time to fix the ancillary header struct.