[dpdk-dev] [PATCH v9 10/20] unci: init netlink

Stephen Hemminger stephen at networkplumber.org
Fri Jun 30 19:29:52 CEST 2017


On Fri, 30 Jun 2017 17:51:30 +0100
Ferruh Yigit <ferruh.yigit at intel.com> wrote:

> +static struct mutex sync_lock;
> +
> +static void nl_recv(struct sk_buff *skb)
> +{
> +	struct nlmsghdr *nlh;
> +	struct unci_nl_msg nl_msg;
> +
> +	nlh = (struct nlmsghdr *)skb->data;
> +
> +	memcpy(&nl_msg, NLMSG_DATA(nlh), sizeof(struct unci_nl_msg));
> +	pr_debug("CMD: %u\n", nl_msg.cmd_id);
> +}
> +
> +static struct netlink_kernel_cfg cfg = {
> +	.input = nl_recv,
> +};
> +
> +void unci_nl_init(void)
> +{
> +	nl_sock = netlink_kernel_create(&init_net, UNCI_NL_GRP, &cfg);
> +	mutex_init(&sync_lock);
> +}

What if netlink socket create fails?

Also, don't need to call mutex_init if you use simpler initailizer.

static DEFINE_MUTEX(sync_lock);



More information about the dev mailing list