netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH iproute2-next v1 3/9] rdma: Add filtering infrastructure
Date: Sun, 7 Jan 2018 09:44:56 +0200	[thread overview]
Message-ID: <20180107074455.GA6823@mtr-leonro.local> (raw)
In-Reply-To: <b7ad60c5-a1c5-ff79-113d-d6c57baf1c40@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1823 bytes --]

On Thu, Jan 04, 2018 at 08:29:31PM -0700, David Ahern wrote:
> On 1/4/18 12:01 AM, Leon Romanovsky wrote:
> > diff --git a/rdma/utils.c b/rdma/utils.c
> > index af2b374d..446c23da 100644
> > --- a/rdma/utils.c
> > +++ b/rdma/utils.c
> > @@ -114,6 +114,225 @@ static void dev_map_cleanup(struct rd *rd)
> >  	}
> >  }
> >
> > +static int add_filter(struct rd *rd, char *key, char *value,
> > +		      const char * const valid_filters[])
> > +{
> > +	char cset[] = "1234567890,-";
> > +	struct filter_entry *fe;
> > +	bool key_found = false;
> > +	int idx = 0;
> > +	int ret;
> > +
> > +	fe = calloc(1, sizeof(*fe));
> > +	if (!fe)
> > +		return -ENOMEM;
> > +
> > +	while (valid_filters[idx]) {
> > +		if (!strcmpx(key, valid_filters[idx])) {
> > +			key_found = true;
> > +			break;
> > +		}
> > +		idx++;
> > +	}
> > +	if (!key_found) {
> > +		pr_err("Unsupported filter option: %s\n", key);
> > +		ret = -EINVAL;
> > +		goto err;
> > +	}
> > +
> > +	/*
> > +	 * Check the filter validity, not optimal, but works
> > +	 *
> > +	 * Actually, there are three types of filters
> > +	 *  numeric - for example PID or QPN
> > +	 *  string  - for example states, currently only "display"
> > +	 *            is from this type
> > +	 *  link    - user requested to filter on specific link
> > +	 *            e.g. mlx5_1/1, mlx5_1/-, mlx5_1 ...
> > +	 */
> > +	if (strcmpx(key, "link") && strcmpx(key, "display") &&
> > +	    strspn(value, cset) != strlen(value)) {
> > +		pr_err("%s filter accepts \"%s\" characters only\n", key, cset);
> > +		ret = -EINVAL;
> > +		goto err;
> > +	}
> > +
> > +	fe->key = strdup(key);
> > +	fe->value = strdup(value);
> > +
>
> Missed this the other day. 2 more strdup's that should be checked.

Thanks, David,

I'll fix and send new version once the RDMA kernel part will be accepted.

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-01-07  7:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04  7:01 [PATCH iproute2-next v1 0/9] RDMA resource tracking Leon Romanovsky
2018-01-04  7:01 ` [PATCH iproute2-next v1 1/9] rdma: Add option to provide "-" sign for the port number Leon Romanovsky
2018-01-04  7:01 ` [PATCH iproute2-next v1 2/9] rdma: Make visible the number of arguments Leon Romanovsky
     [not found] ` <20180104070150.15625-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-04  7:01   ` [PATCH iproute2-next v1 3/9] rdma: Add filtering infrastructure Leon Romanovsky
2018-01-05  3:29     ` David Ahern
2018-01-07  7:44       ` Leon Romanovsky [this message]
2018-01-04  7:01   ` [PATCH iproute2-next v1 4/9] rdma: Set pointer to device name position Leon Romanovsky
2018-01-04  7:01   ` [PATCH iproute2-next v1 8/9] rdma: Add QP resource tracking information Leon Romanovsky
2018-01-04  7:01 ` [PATCH iproute2-next v1 5/9] rdma: Allow external usage of compare string routine Leon Romanovsky
2018-01-04  7:01 ` [PATCH iproute2-next v1 6/9] rdma: Update kernel header file Leon Romanovsky
2018-01-04  7:01 ` [PATCH iproute2-next v1 7/9] rdma: Add resource tracking summary Leon Romanovsky
2018-01-04  7:01 ` [PATCH iproute2-next v1 9/9] rdma: Document resource tracking Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180107074455.GA6823@mtr-leonro.local \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jgg@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).