public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] A Sample of using socket cookie and uid for traffic monitoring
@ 2017-04-04  9:13 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2017-04-04  9:13 UTC (permalink / raw)
  To: kernel-janitors

Hello Chenbo Feng,

The patch 51570a5ab2b7: "A Sample of using socket cookie and uid for
traffic monitoring" from Mar 22, 2017, leads to the following static
checker warning:

	./samples/bpf/cookie_uid_helper_example.c:185 print_table()
	warn: unsigned 'res' is never less than zero.

samples/bpf/cookie_uid_helper_example.c
   176  static void print_table(void)
   177  {
   178          struct stats curEntry;
   179          uint32_t curN = UINT32_MAX;
   180          uint32_t nextN, res;
                                ^^^
Unsigned.

   181  
   182          while (bpf_map_get_next_key(map_fd, &curN, &nextN) > -1) {
   183                  curN = nextN;
   184                  res = bpf_map_lookup_elem(map_fd, &curN, &curEntry);
   185                  if (res < 0) {
                            ^^^^^^^
Not possible.

   186                          error(1, errno, "fail to get entry value of Key: %u\n",
   187                                  curN);
   188                  } else {
   189                          printf("cookie: %u, uid: 0x%x, Packet Count: %lu,"
   190                                  " Bytes Count: %lu\n", curN, curEntry.uid,
   191                                  curEntry.packets, curEntry.bytes);
   192                  }
   193          }
   194  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-04  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-04  9:13 [bug report] A Sample of using socket cookie and uid for traffic monitoring Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox