On 3/30/2018 1:00 AM, Stephen Hemminger wrote:
On Fri, 30 Mar 2018 00:00:04 +0800
Jeff Guo <jia....@intel.com> wrote:

+dev_uev_monitor_create(int netlink_fd)
+{
+       struct sockaddr_nl addr;
+       int ret;
+       int size = 64 * 1024;
+       int nonblock = 1;
+
+       memset(&addr, 0, sizeof(addr));
+       addr.nl_family = AF_NETLINK;
+       addr.nl_pid = 0;
+       addr.nl_groups = 0xffffffff;
+
+       if (bind(netlink_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+               RTE_LOG(ERR, EAL, "Failed to bind socket for netlink fd.\n");
+               goto err;
+       }
+
+       setsockopt(netlink_fd, SOL_SOCKET, SO_PASSCRED, &size, sizeof(size));
+
+       ret = ioctl(netlink_fd, FIONBIO, &nonblock);
+       if (ret != 0) {
+               RTE_LOG(ERR, EAL, "ioctl(FIONBIO) failed.\n");
+               goto err;
+       }
+       return 0;
+err:
You should set close on exec for this fd (with fcntl).
yes, but i have already set it when fd creation time by SOCK_CLOEXEC.

Reply via email to