From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: Re: [patch net-next v6 01/11] net: sched: introduce support for multiple filter chain pointers registration Date: Sat, 6 Jan 2018 18:11:33 +0100 Message-ID: <20180106171133.GC2099@nanopsycho> References: <20180105230929.5645-1-jiri@resnulli.us> <20180105230929.5645-2-jiri@resnulli.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, mlxsw@mellanox.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, michael.chan@broadcom.com, ganeshgr@chelsio.com, saeedm@mellanox.com, matanb@mellanox.com, leonro@mellanox.com, idosch@mellanox.com, jakub.kicinski@netronome.com, simon.horman@netronome.com, pieter.jansenvanvuuren@netronome.com, john.hurley@netronome.com, alexander.h.duyck@intel.com, ogerlitz@mellanox.com, john.fastabend@gmail.com, daniel@iogearbox.net, dsahern@gmail.com To: netdev@vger.kernel.org Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:45344 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753548AbeAFRLg (ORCPT ); Sat, 6 Jan 2018 12:11:36 -0500 Received: by mail-wm0-f66.google.com with SMTP id 9so7397734wme.4 for ; Sat, 06 Jan 2018 09:11:35 -0800 (PST) Content-Disposition: inline In-Reply-To: <20180105230929.5645-2-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org List-ID: Sat, Jan 06, 2018 at 12:09:19AM CET, jiri@resnulli.us wrote: >From: Jiri Pirko > >So far, there was possible only to register a single filter chain >pointer to block->chain[0]. However, when the blocks will get shareable, >we need to allow multiple filter chain pointers registration. > >Signed-off-by: Jiri Pirko >--- [...] >+static int tcf_block_insert(struct tcf_block *block, struct net *net, >+ u32 block_index, struct netlink_ext_ack *extack) >+{ >+ struct tcf_net *tn = net_generic(net, tcf_net_id); >+ int idr_start; >+ int idr_end; >+ int index; >+ >+ if (block_index >= INT_MAX) { >+ NL_SET_ERR_MSG(extack, "Invalid block index value (>= INT_MAX)"); >+ return -EINVAL; >+ } >+ idr_start = block_index ? block_index : 1; >+ idr_end = block_index ? block_index + 1 : INT_MAX; >+ >+ index = idr_alloc(&tn->idr, block, idr_start, idr_end, GFP_KERNEL); Oh, I have to do idr_alloc_ext