From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 8A48E2B9F for ; Fri, 15 Dec 2017 12:39:23 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2017 03:39:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,404,1508828400"; d="scan'208";a="16252510" Received: from silpixa00383879.ir.intel.com (HELO silpixa00383879.ger.corp.intel.com) ([10.237.223.127]) by orsmga001.jf.intel.com with ESMTP; 15 Dec 2017 03:39:20 -0800 From: Radu Nicolau To: dev@dpdk.org Cc: ferruh.yigit@intel.com, pascal.mazon@6wind.com, Radu Nicolau Date: Fri, 15 Dec 2017 11:34:37 +0000 Message-Id: <1513337677-29923-1-git-send-email-radu.nicolau@intel.com> X-Mailer: git-send-email 2.7.5 Subject: [dpdk-dev] [PATCH] net/tap: renamed netlink functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Dec 2017 11:39:24 -0000 Functions like nl_recev and nl_send name clash functions in the libnl library (https://www.infradead.org/~tgr/libnl/). All functions declared in tap_netlink.h were decorated with tap_ for consistency. Signed-off-by: Radu Nicolau --- drivers/net/tap/rte_eth_tap.c | 12 ++-- drivers/net/tap/tap_flow.c | 129 +++++++++++++++++++++--------------------- drivers/net/tap/tap_netlink.c | 41 +++++++------- drivers/net/tap/tap_netlink.h | 25 ++++---- drivers/net/tap/tap_tcmsgs.c | 28 ++++----- 5 files changed, 120 insertions(+), 115 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 6b27679..a0e223a 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -1123,7 +1123,7 @@ tap_dev_intr_handler(void *cb_arg) struct rte_eth_dev *dev = cb_arg; struct pmd_internals *pmd = dev->data->dev_private; - nl_recv(pmd->intr_handle.fd, tap_nl_msg_handler, dev); + tap_nl_recv(pmd->intr_handle.fd, tap_nl_msg_handler, dev); } static int @@ -1134,20 +1134,20 @@ tap_intr_handle_set(struct rte_eth_dev *dev, int set) /* In any case, disable interrupt if the conf is no longer there. */ if (!dev->data->dev_conf.intr_conf.lsc) { if (pmd->intr_handle.fd != -1) { - nl_final(pmd->intr_handle.fd); + tap_nl_final(pmd->intr_handle.fd); rte_intr_callback_unregister(&pmd->intr_handle, tap_dev_intr_handler, dev); } return 0; } if (set) { - pmd->intr_handle.fd = nl_init(RTMGRP_LINK); + pmd->intr_handle.fd = tap_nl_init(RTMGRP_LINK); if (unlikely(pmd->intr_handle.fd == -1)) return -EBADF; return rte_intr_callback_register( &pmd->intr_handle, tap_dev_intr_handler, dev); } - nl_final(pmd->intr_handle.fd); + tap_nl_final(pmd->intr_handle.fd); return rte_intr_callback_unregister(&pmd->intr_handle, tap_dev_intr_handler, dev); } @@ -1328,7 +1328,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, * - rte_flow actual/implicit lists * - implicit rules */ - pmd->nlsk_fd = nl_init(0); + pmd->nlsk_fd = tap_nl_init(0); if (pmd->nlsk_fd == -1) { RTE_LOG(WARNING, PMD, "%s: failed to create netlink socket.\n", pmd->name); @@ -1579,7 +1579,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) if (internals->nlsk_fd) { tap_flow_flush(eth_dev, NULL); tap_flow_implicit_flush(internals, NULL); - nl_final(internals->nlsk_fd); + tap_nl_final(internals->nlsk_fd); } for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { if (internals->rxq[i].fd != -1) { diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index ffc0b85..90b2654 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -465,16 +465,16 @@ tap_flow_create_eth(const struct rte_flow_item *item, void *data) return 0; msg = &flow->msg; if (!is_zero_ether_addr(&spec->dst)) { - nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_DST, ETHER_ADDR_LEN, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_DST, ETHER_ADDR_LEN, &spec->dst.addr_bytes); - nlattr_add(&msg->nh, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_DST_MASK, ETHER_ADDR_LEN, &mask->dst.addr_bytes); } if (!is_zero_ether_addr(&mask->src)) { - nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_SRC, ETHER_ADDR_LEN, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_SRC, ETHER_ADDR_LEN, &spec->src.addr_bytes); - nlattr_add(&msg->nh, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_SRC_MASK, ETHER_ADDR_LEN, &mask->src.addr_bytes); } @@ -526,9 +526,11 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) uint8_t vid = VLAN_ID(tci); if (prio) - nlattr_add8(&msg->nh, TCA_FLOWER_KEY_VLAN_PRIO, prio); + tap_nlattr_add8(&msg->nh, + TCA_FLOWER_KEY_VLAN_PRIO, prio); if (vid) - nlattr_add16(&msg->nh, TCA_FLOWER_KEY_VLAN_ID, vid); + tap_nlattr_add16(&msg->nh, + TCA_FLOWER_KEY_VLAN_ID, vid); } return 0; } @@ -571,19 +573,19 @@ tap_flow_create_ipv4(const struct rte_flow_item *item, void *data) if (!spec) return 0; if (spec->hdr.dst_addr) { - nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST, + tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST, spec->hdr.dst_addr); - nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST_MASK, + tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST_MASK, mask->hdr.dst_addr); } if (spec->hdr.src_addr) { - nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC, + tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC, spec->hdr.src_addr); - nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC_MASK, + tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC_MASK, mask->hdr.src_addr); } if (spec->hdr.next_proto_id) - nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, + tap_nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, spec->hdr.next_proto_id); return 0; } @@ -627,19 +629,20 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data) if (!spec) return 0; if (memcmp(spec->hdr.dst_addr, empty_addr, 16)) { - nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST, sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr); - nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK, sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr); } if (memcmp(spec->hdr.src_addr, empty_addr, 16)) { - nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC, sizeof(spec->hdr.src_addr), &spec->hdr.src_addr); - nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK, + tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK, sizeof(mask->hdr.src_addr), &mask->hdr.src_addr); } if (spec->hdr.proto) - nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, spec->hdr.proto); + tap_nlattr_add8(&msg->nh, + TCA_FLOWER_KEY_IP_PROTO, spec->hdr.proto); return 0; } @@ -677,14 +680,14 @@ tap_flow_create_udp(const struct rte_flow_item *item, void *data) if (!flow) return 0; msg = &flow->msg; - nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_UDP); + tap_nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_UDP); if (!spec) return 0; if (spec->hdr.dst_port & mask->hdr.dst_port) - nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_DST, + tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_DST, spec->hdr.dst_port); if (spec->hdr.src_port & mask->hdr.src_port) - nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_SRC, + tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_SRC, spec->hdr.src_port); return 0; } @@ -723,14 +726,14 @@ tap_flow_create_tcp(const struct rte_flow_item *item, void *data) if (!flow) return 0; msg = &flow->msg; - nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_TCP); + tap_nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_TCP); if (!spec) return 0; if (spec->hdr.dst_port & mask->hdr.dst_port) - nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_DST, + tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_DST, spec->hdr.dst_port); if (spec->hdr.src_port & mask->hdr.src_port) - nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_SRC, + tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_SRC, spec->hdr.src_port); return 0; } @@ -835,17 +838,17 @@ add_action_gact(struct rte_flow *flow, int action) .action = action }; - if (nlattr_nested_start(msg, TCA_FLOWER_ACT) < 0) + if (tap_nlattr_nested_start(msg, TCA_FLOWER_ACT) < 0) return -1; - if (nlattr_nested_start(msg, act_index++) < 0) + if (tap_nlattr_nested_start(msg, act_index++) < 0) return -1; - nlattr_add(&msg->nh, TCA_ACT_KIND, sizeof("gact"), "gact"); - if (nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0) + tap_nlattr_add(&msg->nh, TCA_ACT_KIND, sizeof("gact"), "gact"); + if (tap_nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0) return -1; - nlattr_add(&msg->nh, TCA_GACT_PARMS, sizeof(p), &p); - nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */ - nlattr_nested_finish(msg); /* nested act_index */ - nlattr_nested_finish(msg); /* nested TCA_FLOWER_ACT */ + tap_nlattr_add(&msg->nh, TCA_GACT_PARMS, sizeof(p), &p); + tap_nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */ + tap_nlattr_nested_finish(msg); /* nested act_index */ + tap_nlattr_nested_finish(msg); /* nested TCA_FLOWER_ACT */ return 0; } @@ -872,21 +875,21 @@ add_action_mirred(struct rte_flow *flow, uint16_t ifindex, uint16_t action_type) .ifindex = ifindex, }; - if (nlattr_nested_start(msg, TCA_FLOWER_ACT) < 0) + if (tap_nlattr_nested_start(msg, TCA_FLOWER_ACT) < 0) return -1; - if (nlattr_nested_start(msg, act_index++) < 0) + if (tap_nlattr_nested_start(msg, act_index++) < 0) return -1; - nlattr_add(&msg->nh, TCA_ACT_KIND, sizeof("mirred"), "mirred"); - if (nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0) + tap_nlattr_add(&msg->nh, TCA_ACT_KIND, sizeof("mirred"), "mirred"); + if (tap_nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0) return -1; if (action_type == TCA_EGRESS_MIRROR) p.action = TC_ACT_PIPE; else /* REDIRECT */ p.action = TC_ACT_STOLEN; - nlattr_add(&msg->nh, TCA_MIRRED_PARMS, sizeof(p), &p); - nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */ - nlattr_nested_finish(msg); /* nested act_index */ - nlattr_nested_finish(msg); /* nested TCA_FLOWER_ACT */ + tap_nlattr_add(&msg->nh, TCA_MIRRED_PARMS, sizeof(p), &p); + tap_nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */ + tap_nlattr_nested_finish(msg); /* nested act_index */ + tap_nlattr_nested_finish(msg); /* nested TCA_FLOWER_ACT */ return 0; } @@ -910,18 +913,18 @@ add_action_skbedit(struct rte_flow *flow, uint16_t queue) .action = TC_ACT_PIPE }; - if (nlattr_nested_start(msg, TCA_FLOWER_ACT) < 0) + if (tap_nlattr_nested_start(msg, TCA_FLOWER_ACT) < 0) return -1; - if (nlattr_nested_start(msg, act_index++) < 0) + if (tap_nlattr_nested_start(msg, act_index++) < 0) return -1; - nlattr_add(&msg->nh, TCA_ACT_KIND, sizeof("skbedit"), "skbedit"); - if (nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0) + tap_nlattr_add(&msg->nh, TCA_ACT_KIND, sizeof("skbedit"), "skbedit"); + if (tap_nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0) return -1; - nlattr_add(&msg->nh, TCA_SKBEDIT_PARMS, sizeof(p), &p); - nlattr_add16(&msg->nh, TCA_SKBEDIT_QUEUE_MAPPING, queue); - nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */ - nlattr_nested_finish(msg); /* nested act_index */ - nlattr_nested_finish(msg); /* nested TCA_FLOWER_ACT */ + tap_nlattr_add(&msg->nh, TCA_SKBEDIT_PARMS, sizeof(p), &p); + tap_nlattr_add16(&msg->nh, TCA_SKBEDIT_QUEUE_MAPPING, queue); + tap_nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */ + tap_nlattr_nested_finish(msg); /* nested act_index */ + tap_nlattr_nested_finish(msg); /* nested TCA_FLOWER_ACT */ return 0; } @@ -1004,8 +1007,8 @@ priv_flow_process(struct pmd_internals *pmd, TC_H_MAKE(MULTIQ_MAJOR_HANDLE, 0); } /* use flower filter type */ - nlattr_add(&flow->msg.nh, TCA_KIND, sizeof("flower"), "flower"); - if (nlattr_nested_start(&flow->msg, TCA_OPTIONS) < 0) + tap_nlattr_add(&flow->msg.nh, TCA_KIND, sizeof("flower"), "flower"); + if (tap_nlattr_nested_start(&flow->msg, TCA_OPTIONS) < 0) goto exit_item_not_supported; } for (; items->type != RTE_FLOW_ITEM_TYPE_END; ++items) { @@ -1041,14 +1044,14 @@ priv_flow_process(struct pmd_internals *pmd, } if (flow) { if (data.vlan) { - nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE, + tap_nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE, htons(ETH_P_8021Q)); - nlattr_add16(&flow->msg.nh, + tap_nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_VLAN_ETH_TYPE, data.eth_type ? data.eth_type : htons(ETH_P_ALL)); } else if (data.eth_type) { - nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE, + tap_nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE, data.eth_type); } } @@ -1120,7 +1123,7 @@ priv_flow_process(struct pmd_internals *pmd, } end: if (flow) - nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ + tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ return 0; exit_item_not_supported: rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, @@ -1232,13 +1235,13 @@ tap_flow_create(struct rte_eth_dev *dev, tap_flow_set_handle(flow); if (priv_flow_process(pmd, attr, items, actions, error, flow, 0)) goto fail; - err = nl_send(pmd->nlsk_fd, &msg->nh); + err = tap_nl_send(pmd->nlsk_fd, &msg->nh); if (err < 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "couldn't send request to kernel"); goto fail; } - err = nl_recv_ack(pmd->nlsk_fd); + err = tap_nl_recv_ack(pmd->nlsk_fd); if (err < 0) { RTE_LOG(ERR, PMD, "Kernel refused TC filter rule creation (%d): %s\n", @@ -1276,14 +1279,14 @@ tap_flow_create(struct rte_eth_dev *dev, NULL, "rte flow rule validation failed"); goto fail; } - err = nl_send(pmd->nlsk_fd, &msg->nh); + err = tap_nl_send(pmd->nlsk_fd, &msg->nh); if (err < 0) { rte_flow_error_set( error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "Failure sending nl request"); goto fail; } - err = nl_recv_ack(pmd->nlsk_fd); + err = tap_nl_recv_ack(pmd->nlsk_fd); if (err < 0) { RTE_LOG(ERR, PMD, "Kernel refused TC filter rule creation (%d): %s\n", @@ -1329,13 +1332,13 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd, flow->msg.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; flow->msg.nh.nlmsg_type = RTM_DELTFILTER; - ret = nl_send(pmd->nlsk_fd, &flow->msg.nh); + ret = tap_nl_send(pmd->nlsk_fd, &flow->msg.nh); if (ret < 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "couldn't send request to kernel"); goto end; } - ret = nl_recv_ack(pmd->nlsk_fd); + ret = tap_nl_recv_ack(pmd->nlsk_fd); /* If errno is ENOENT, the rule is already no longer in the kernel. */ if (ret < 0 && errno == ENOENT) ret = 0; @@ -1352,14 +1355,14 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd, remote_flow->msg.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; remote_flow->msg.nh.nlmsg_type = RTM_DELTFILTER; - ret = nl_send(pmd->nlsk_fd, &remote_flow->msg.nh); + ret = tap_nl_send(pmd->nlsk_fd, &remote_flow->msg.nh); if (ret < 0) { rte_flow_error_set( error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "Failure sending nl request"); goto end; } - ret = nl_recv_ack(pmd->nlsk_fd); + ret = tap_nl_recv_ack(pmd->nlsk_fd); if (ret < 0 && errno == ENOENT) ret = 0; if (ret < 0) { @@ -1566,12 +1569,12 @@ int tap_flow_implicit_create(struct pmd_internals *pmd, RTE_LOG(ERR, PMD, "rte flow rule validation failed\n"); goto fail; } - err = nl_send(pmd->nlsk_fd, &msg->nh); + err = tap_nl_send(pmd->nlsk_fd, &msg->nh); if (err < 0) { RTE_LOG(ERR, PMD, "Failure sending nl request\n"); goto fail; } - err = nl_recv_ack(pmd->nlsk_fd); + err = tap_nl_recv_ack(pmd->nlsk_fd); if (err < 0) { RTE_LOG(ERR, PMD, "Kernel refused TC filter rule creation (%d): %s\n", diff --git a/drivers/net/tap/tap_netlink.c b/drivers/net/tap/tap_netlink.c index ee92e2e..a10f647 100644 --- a/drivers/net/tap/tap_netlink.c +++ b/drivers/net/tap/tap_netlink.c @@ -63,7 +63,7 @@ struct nested_tail { * netlink socket file descriptor on success, -1 otherwise. */ int -nl_init(uint32_t nl_groups) +tap_nl_init(uint32_t nl_groups) { int fd, sndbuf_size = SNDBUF_SIZE, rcvbuf_size = RCVBUF_SIZE; struct sockaddr_nl local = { @@ -101,7 +101,7 @@ nl_init(uint32_t nl_groups) * 0 on success, -1 otherwise. */ int -nl_final(int nlsk_fd) +tap_nl_final(int nlsk_fd) { if (close(nlsk_fd)) { RTE_LOG(ERR, PMD, "Failed to close netlink socket: %s (%d)\n", @@ -123,7 +123,7 @@ nl_final(int nlsk_fd) * the number of sent bytes on success, -1 otherwise. */ int -nl_send(int nlsk_fd, struct nlmsghdr *nh) +tap_nl_send(int nlsk_fd, struct nlmsghdr *nh) { /* man 7 netlink EXAMPLE */ struct sockaddr_nl sa = { @@ -153,7 +153,8 @@ nl_send(int nlsk_fd, struct nlmsghdr *nh) } /** - * Check that the kernel sends an appropriate ACK in response to an nl_send(). + * Check that the kernel sends an appropriate ACK in response + * to an tap_nl_send(). * * @param[in] nlsk_fd * The netlink socket file descriptor used for communication. @@ -162,14 +163,14 @@ nl_send(int nlsk_fd, struct nlmsghdr *nh) * 0 on success, -1 otherwise with errno set. */ int -nl_recv_ack(int nlsk_fd) +tap_nl_recv_ack(int nlsk_fd) { - return nl_recv(nlsk_fd, NULL, NULL); + return tap_nl_recv(nlsk_fd, NULL, NULL); } /** * Receive a message from the kernel on the netlink socket, following an - * nl_send(). + * tap_nl_send(). * * @param[in] nlsk_fd * The netlink socket file descriptor used for communication. @@ -182,7 +183,7 @@ nl_recv_ack(int nlsk_fd) * 0 on success, -1 otherwise with errno set. */ int -nl_recv(int nlsk_fd, int (*cb)(struct nlmsghdr *, void *arg), void *arg) +tap_nl_recv(int nlsk_fd, int (*cb)(struct nlmsghdr *, void *arg), void *arg) { /* man 7 netlink EXAMPLE */ struct sockaddr_nl sa; @@ -247,7 +248,7 @@ nl_recv(int nlsk_fd, int (*cb)(struct nlmsghdr *, void *arg), void *arg) * The data to append. */ void -nlattr_add(struct nlmsghdr *nh, unsigned short type, +tap_nlattr_add(struct nlmsghdr *nh, unsigned short type, unsigned int data_len, const void *data) { /* see man 3 rtnetlink */ @@ -271,9 +272,9 @@ nlattr_add(struct nlmsghdr *nh, unsigned short type, * The data to append. */ void -nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data) +tap_nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data) { - nlattr_add(nh, type, sizeof(uint8_t), &data); + tap_nlattr_add(nh, type, sizeof(uint8_t), &data); } /** @@ -287,9 +288,9 @@ nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data) * The data to append. */ void -nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data) +tap_nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data) { - nlattr_add(nh, type, sizeof(uint16_t), &data); + tap_nlattr_add(nh, type, sizeof(uint16_t), &data); } /** @@ -303,14 +304,14 @@ nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data) * The data to append. */ void -nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data) +tap_nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data) { - nlattr_add(nh, type, sizeof(uint32_t), &data); + tap_nlattr_add(nh, type, sizeof(uint32_t), &data); } /** * Start a nested netlink attribute. - * It must be followed later by a call to nlattr_nested_finish(). + * It must be followed later by a call to tap_nlattr_nested_finish(). * * @param[in, out] msg * The netlink message where to edit the nested_tails metadata. @@ -321,7 +322,7 @@ nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data) * -1 if adding a nested netlink attribute failed, 0 otherwise. */ int -nlattr_nested_start(struct nlmsg *msg, uint16_t type) +tap_nlattr_nested_start(struct nlmsg *msg, uint16_t type) { struct nested_tail *tail; @@ -335,7 +336,7 @@ nlattr_nested_start(struct nlmsg *msg, uint16_t type) tail->tail = (struct rtattr *)NLMSG_TAIL(&msg->nh); - nlattr_add(&msg->nh, type, 0, NULL); + tap_nlattr_add(&msg->nh, type, 0, NULL); tail->prev = msg->nested_tails; @@ -346,7 +347,7 @@ nlattr_nested_start(struct nlmsg *msg, uint16_t type) /** * End a nested netlink attribute. - * It follows a call to nlattr_nested_start(). + * It follows a call to tap_nlattr_nested_start(). * In effect, it will modify the nested attribute length to include every bytes * from the nested attribute start, up to here. * @@ -354,7 +355,7 @@ nlattr_nested_start(struct nlmsg *msg, uint16_t type) * The netlink message where to edit the nested_tails metadata. */ void -nlattr_nested_finish(struct nlmsg *msg) +tap_nlattr_nested_finish(struct nlmsg *msg) { struct nested_tail *tail = msg->nested_tails; diff --git a/drivers/net/tap/tap_netlink.h b/drivers/net/tap/tap_netlink.h index 98e1390..a8affea 100644 --- a/drivers/net/tap/tap_netlink.h +++ b/drivers/net/tap/tap_netlink.h @@ -53,17 +53,18 @@ struct nlmsg { #define NLMSG_TAIL(nlh) (void *)((char *)(nlh) + NLMSG_ALIGN((nlh)->nlmsg_len)) -int nl_init(uint32_t nl_groups); -int nl_final(int nlsk_fd); -int nl_send(int nlsk_fd, struct nlmsghdr *nh); -int nl_recv(int nlsk_fd, int (*callback)(struct nlmsghdr *, void *), void *arg); -int nl_recv_ack(int nlsk_fd); -void nlattr_add(struct nlmsghdr *nh, unsigned short type, - unsigned int data_len, const void *data); -void nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data); -void nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data); -void nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data); -int nlattr_nested_start(struct nlmsg *msg, uint16_t type); -void nlattr_nested_finish(struct nlmsg *msg); +int tap_nl_init(uint32_t nl_groups); +int tap_nl_final(int nlsk_fd); +int tap_nl_send(int nlsk_fd, struct nlmsghdr *nh); +int tap_nl_recv(int nlsk_fd, int (*callback)(struct nlmsghdr *, void *), + void *arg); +int tap_nl_recv_ack(int nlsk_fd); +void tap_nlattr_add(struct nlmsghdr *nh, unsigned short type, + unsigned int data_len, const void *data); +void tap_nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data); +void tap_nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data); +void tap_nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data); +int tap_nlattr_nested_start(struct nlmsg *msg, uint16_t type); +void tap_nlattr_nested_finish(struct nlmsg *msg); #endif /* _TAP_NETLINK_H_ */ diff --git a/drivers/net/tap/tap_tcmsgs.c b/drivers/net/tap/tap_tcmsgs.c index d74ac80..865c22b 100644 --- a/drivers/net/tap/tap_tcmsgs.c +++ b/drivers/net/tap/tap_tcmsgs.c @@ -107,7 +107,7 @@ qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo) msg.t.tcm_parent = qinfo->parent; /* if no netlink socket is provided, create one */ if (!nlsk_fd) { - fd = nl_init(0); + fd = tap_nl_init(0); if (fd < 0) { RTE_LOG(ERR, PMD, "Could not delete QDISC: null netlink socket\n"); @@ -116,16 +116,16 @@ qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo) } else { fd = nlsk_fd; } - if (nl_send(fd, &msg.nh) < 0) + if (tap_nl_send(fd, &msg.nh) < 0) goto error; - if (nl_recv_ack(fd) < 0) + if (tap_nl_recv_ack(fd) < 0) goto error; if (!nlsk_fd) - return nl_final(fd); + return tap_nl_final(fd); return 0; error: if (!nlsk_fd) - nl_final(fd); + tap_nl_final(fd); return -1; } @@ -150,11 +150,11 @@ qdisc_add_multiq(int nlsk_fd, uint16_t ifindex) NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE); msg.t.tcm_handle = TC_H_MAKE(MULTIQ_MAJOR_HANDLE, 0); msg.t.tcm_parent = TC_H_ROOT; - nlattr_add(&msg.nh, TCA_KIND, sizeof("multiq"), "multiq"); - nlattr_add(&msg.nh, TCA_OPTIONS, sizeof(opt), &opt); - if (nl_send(nlsk_fd, &msg.nh) < 0) + tap_nlattr_add(&msg.nh, TCA_KIND, sizeof("multiq"), "multiq"); + tap_nlattr_add(&msg.nh, TCA_OPTIONS, sizeof(opt), &opt); + if (tap_nl_send(nlsk_fd, &msg.nh) < 0) return -1; - if (nl_recv_ack(nlsk_fd) < 0) + if (tap_nl_recv_ack(nlsk_fd) < 0) return -1; return 0; } @@ -179,10 +179,10 @@ qdisc_add_ingress(int nlsk_fd, uint16_t ifindex) NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE); msg.t.tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0); msg.t.tcm_parent = TC_H_INGRESS; - nlattr_add(&msg.nh, TCA_KIND, sizeof("ingress"), "ingress"); - if (nl_send(nlsk_fd, &msg.nh) < 0) + tap_nlattr_add(&msg.nh, TCA_KIND, sizeof("ingress"), "ingress"); + if (tap_nl_send(nlsk_fd, &msg.nh) < 0) return -1; - if (nl_recv_ack(nlsk_fd) < 0) + if (tap_nl_recv_ack(nlsk_fd) < 0) return -1; return 0; } @@ -246,9 +246,9 @@ qdisc_iterate(int nlsk_fd, uint16_t ifindex, }; tc_init_msg(&msg, ifindex, RTM_GETQDISC, NLM_F_REQUEST | NLM_F_DUMP); - if (nl_send(nlsk_fd, &msg.nh) < 0) + if (tap_nl_send(nlsk_fd, &msg.nh) < 0) return -1; - if (nl_recv(nlsk_fd, callback, &args) < 0) + if (tap_nl_recv(nlsk_fd, callback, &args) < 0) return -1; return 0; } -- 2.7.5