aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/unix
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-09-08 19:52:02 +0200
committerFlorin Coras <florin.coras@gmail.com>2017-09-09 20:11:03 +0000
commit56dd5438b04b869065d8e901c315496bb6777455 (patch)
tree517190c53cfd2725d716eda6dddf9a64ad814084 /src/vnet/unix
parent816122e303efb5012f6897bd53ff8fe28cd8fa1c (diff)
move unix_file_* code to vppinfra
This will allow us to use this code in client libraries without vlib. Change-Id: I8557b752496841ba588aa36b6082cbe2cd1867fe Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/unix')
-rw-r--r--src/vnet/unix/tapcli.c19
-rw-r--r--src/vnet/unix/tuntap.c10
2 files changed, 13 insertions, 16 deletions
diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c
index 0fc62f6c061..13154b3b034 100644
--- a/src/vnet/unix/tapcli.c
+++ b/src/vnet/unix/tapcli.c
@@ -56,7 +56,7 @@ static void tapcli_nopunt_frame (vlib_main_t * vm,
*/
typedef struct {
u32 unix_fd;
- u32 unix_file_index;
+ u32 clib_file_index;
u32 provision_fd;
/** For counters */
u32 sw_if_index;
@@ -137,8 +137,6 @@ typedef struct {
vlib_main_t * vlib_main;
/** convenience - vnet_main_t */
vnet_main_t * vnet_main;
- /** convenience - unix_main_t */
- unix_main_t * unix_main;
} tapcli_main_t;
static tapcli_main_t tapcli_main;
@@ -453,12 +451,12 @@ VLIB_REGISTER_NODE (tapcli_rx_node, static) = {
/**
* @brief Gets called when file descriptor is ready from epoll.
*
- * @param *uf - unix_file_t
+ * @param *uf - clib_file_t
*
* @return error - clib_error_t
*
*/
-static clib_error_t * tapcli_read_ready (unix_file_t * uf)
+static clib_error_t * tapcli_read_ready (clib_file_t * uf)
{
vlib_main_t * vm = vlib_get_main();
tapcli_main_t * tm = &tapcli_main;
@@ -999,10 +997,10 @@ int vnet_tap_connect (vlib_main_t * vm, vnet_tap_connect_args_t *ap)
}
{
- unix_file_t template = {0};
+ clib_file_t template = {0};
template.read_function = tapcli_read_ready;
template.file_descriptor = dev_net_tun_fd;
- ti->unix_file_index = unix_file_add (&unix_main, &template);
+ ti->clib_file_index = clib_file_add (&file_main, &template);
ti->unix_fd = dev_net_tun_fd;
ti->provision_fd = dev_tap_fd;
clib_memcpy (&ti->ifr, &ifr, sizeof (ifr));
@@ -1079,9 +1077,9 @@ static int tapcli_tap_disconnect (tapcli_interface_t *ti)
// bring interface down
vnet_sw_interface_set_flags (vnm, sw_if_index, 0);
- if (ti->unix_file_index != ~0) {
- unix_file_del (&unix_main, unix_main.file_pool + ti->unix_file_index);
- ti->unix_file_index = ~0;
+ if (ti->clib_file_index != ~0) {
+ clib_file_del (&file_main, file_main.file_pool + ti->clib_file_index);
+ ti->clib_file_index = ~0;
}
else
close(ti->unix_fd);
@@ -1455,7 +1453,6 @@ tapcli_init (vlib_main_t * vm)
tm->vlib_main = vm;
tm->vnet_main = vnet_get_main();
- tm->unix_main = &unix_main;
tm->mtu_bytes = TAP_MTU_DEFAULT;
tm->tapcli_interface_index_by_sw_if_index = hash_create (0, sizeof(uword));
tm->tapcli_interface_index_by_unix_fd = hash_create (0, sizeof (uword));
diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c
index 2c403679349..9616feb2d51 100644
--- a/src/vnet/unix/tuntap.c
+++ b/src/vnet/unix/tuntap.c
@@ -104,7 +104,7 @@ typedef struct {
mhash_t subif_mhash;
/** Unix file index */
- u32 unix_file_index;
+ u32 clib_file_index;
/** For the "normal" interface, if configured */
u32 hw_if_index, sw_if_index;
@@ -388,11 +388,11 @@ VLIB_REGISTER_NODE (tuntap_rx_node,static) = {
/**
* @brief Gets called when file descriptor is ready from epoll.
*
- * @param *uf - unix_file_t
+ * @param *uf - clib_file_t
*
* @return error - clib_error_t
*/
-static clib_error_t * tuntap_read_ready (unix_file_t * uf)
+static clib_error_t * tuntap_read_ready (clib_file_t * uf)
{
vlib_main_t * vm = vlib_get_main();
vlib_node_set_interrupt_pending (vm, tuntap_rx_node.index);
@@ -645,10 +645,10 @@ tuntap_config (vlib_main_t * vm, unformat_input_t * input)
}
{
- unix_file_t template = {0};
+ clib_file_t template = {0};
template.read_function = tuntap_read_ready;
template.file_descriptor = tm->dev_net_tun_fd;
- tm->unix_file_index = unix_file_add (&unix_main, &template);
+ tm->clib_file_index = clib_file_add (&file_main, &template);
}
done: