aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/tap/tap.c44
-rw-r--r--src/vnet/devices/tap/tap.h15
-rw-r--r--src/vnet/devices/tap/tapv2.api22
-rw-r--r--src/vnet/devices/tap/tapv2_api.c25
-rw-r--r--src/vnet/devices/virtio/device.c2
-rw-r--r--src/vnet/devices/virtio/node.c2
-rw-r--r--src/vnet/devices/virtio/virtio.c2
-rw-r--r--src/vnet/devices/virtio/virtio.h9
8 files changed, 114 insertions, 7 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index 4f76321071c..ff7bd91e8db 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -335,10 +335,22 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
args->mac_addr[0] = 2;
args->mac_addr[1] = 0xfe;
}
+ vif->rx_ring_sz = args->rx_ring_sz != 0 ? args->rx_ring_sz : 256;
+ vif->tx_ring_sz = args->tx_ring_sz != 0 ? args->tx_ring_sz : 256;
vif->host_if_name = args->host_if_name;
args->host_if_name = 0;
vif->net_ns = args->host_namespace;
args->host_namespace = 0;
+ vif->host_bridge = args->host_bridge;
+ args->host_bridge = 0;
+ clib_memcpy (vif->host_mac_addr, args->host_mac_addr, 6);
+ vif->host_ip4_prefix_len = args->host_ip4_prefix_len;
+ vif->host_ip6_prefix_len = args->host_ip6_prefix_len;
+ if (args->host_ip4_prefix_len)
+ clib_memcpy (&vif->host_ip4_addr, &args->host_ip4_addr, 4);
+ if (args->host_ip6_prefix_len)
+ clib_memcpy (&vif->host_ip6_addr, &args->host_ip6_addr, 16);
+
args->error = ethernet_register_interface (vnm, virtio_device_class.index,
vif->dev_instance,
args->mac_addr,
@@ -441,11 +453,39 @@ tap_dump_ifs (tap_interface_details_t ** out_tapids)
pool_foreach (vif, mm->interfaces,
vec_add2(r_tapids, tapid, 1);
memset (tapid, 0, sizeof (*tapid));
+ tapid->id = vif->id;
tapid->sw_if_index = vif->sw_if_index;
hi = vnet_get_hw_interface (vnm, vif->hw_if_index);
clib_memcpy(tapid->dev_name, hi->name,
- MIN (ARRAY_LEN (tapid->dev_name) - 1,
- strlen ((const char *) hi->name)));
+ MIN (ARRAY_LEN (tapid->dev_name) - 1,
+ strlen ((const char *) hi->name)));
+ tapid->rx_ring_sz = vif->rx_ring_sz;
+ tapid->tx_ring_sz = vif->tx_ring_sz;
+ clib_memcpy(tapid->host_mac_addr, vif->host_mac_addr, 6);
+ if (vif->host_if_name)
+ {
+ clib_memcpy(tapid->host_if_name, vif->host_if_name,
+ MIN (ARRAY_LEN (tapid->host_if_name) - 1,
+ strlen ((const char *) vif->host_if_name)));
+ }
+ if (vif->net_ns)
+ {
+ clib_memcpy(tapid->host_namespace, vif->net_ns,
+ MIN (ARRAY_LEN (tapid->host_namespace) - 1,
+ strlen ((const char *) vif->net_ns)));
+ }
+ if (vif->host_bridge)
+ {
+ clib_memcpy(tapid->host_bridge, vif->host_bridge,
+ MIN (ARRAY_LEN (tapid->host_bridge) - 1,
+ strlen ((const char *) vif->host_bridge)));
+ }
+ if (vif->host_ip4_prefix_len)
+ clib_memcpy(tapid->host_ip4_addr, &vif->host_ip4_addr, 4);
+ tapid->host_ip4_prefix_len = vif->host_ip4_prefix_len;
+ if (vif->host_ip6_prefix_len)
+ clib_memcpy(tapid->host_ip6_addr, &vif->host_ip6_addr, 16);
+ tapid->host_ip6_prefix_len = vif->host_ip6_prefix_len;
);
/* *INDENT-ON* */
diff --git a/src/vnet/devices/tap/tap.h b/src/vnet/devices/tap/tap.h
index 7d07ffb4e82..35f7a018237 100644
--- a/src/vnet/devices/tap/tap.h
+++ b/src/vnet/devices/tap/tap.h
@@ -34,9 +34,9 @@ typedef struct
u8 host_mac_addr[6];
u8 *host_bridge;
ip4_address_t host_ip4_addr;
- u32 host_ip4_prefix_len;
+ u8 host_ip4_prefix_len;
ip6_address_t host_ip6_addr;
- u32 host_ip6_prefix_len;
+ u8 host_ip6_prefix_len;
/* return */
u32 sw_if_index;
int rv;
@@ -46,8 +46,19 @@ typedef struct
/** TAP interface details struct */
typedef struct
{
+ u32 id;
u32 sw_if_index;
u8 dev_name[64];
+ u16 tx_ring_sz;
+ u16 rx_ring_sz;
+ u8 host_mac_addr[6];
+ u8 host_if_name[64];
+ u8 host_namespace[64];
+ u8 host_bridge[64];
+ u8 host_ip4_addr[4];
+ u8 host_ip4_prefix_len;
+ u8 host_ip6_addr[16];
+ u8 host_ip6_prefix_len;
} tap_interface_details_t;
typedef struct
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index a2062696709..1f0051ec86f 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -102,13 +102,35 @@ define sw_interface_tap_v2_dump
/** \brief Reply for tap dump request
@param sw_if_index - software index of tap interface
+ @param id - interface id
@param dev_name - Linux tap device name
+ @param tx_ring_sz - the number of entries of TX ring
+ @param rx_ring_sz - the number of entries of RX ring
+ @param host_mac_addr - mac address assigned to the host side of the interface
+ @param host_if_name - host side interface name
+ @param host_namespace - host namespace the interface is attached into
+ @param host_bridge - host bridge the interface is attached into
+ @param host_ip4_addr - host IPv4 ip address
+ @param host_ip4_prefix_len - host IPv4 ip address prefix length; 0 if unset
+ @param host_ip6_addr - host IPv6 ip address
+ @param host_ip6_prefix_len - host IPv6 ip address prefix length; 0 if unset
*/
define sw_interface_tap_v2_details
{
u32 context;
u32 sw_if_index;
+ u32 id;
u8 dev_name[64];
+ u16 tx_ring_sz;
+ u16 rx_ring_sz;
+ u8 host_mac_addr[6];
+ u8 host_if_name[64];
+ u8 host_namespace[64];
+ u8 host_bridge[64];
+ u8 host_ip4_addr[4];
+ u8 host_ip4_prefix_len;
+ u8 host_ip6_addr[16];
+ u8 host_ip6_prefix_len;
};
/*
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 3cededbfe82..841d21e2d25 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -164,13 +164,32 @@ tap_send_sw_interface_details (vpe_api_main_t * am,
vl_api_sw_interface_tap_v2_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_TAP_V2_DETAILS);
- mp->sw_if_index = ntohl (tap_if->sw_if_index);
+ mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_TAP_V2_DETAILS);
+ mp->id = htonl (tap_if->id);
+ mp->sw_if_index = htonl (tap_if->sw_if_index);
clib_memcpy (mp->dev_name, tap_if->dev_name,
MIN (ARRAY_LEN (mp->dev_name) - 1,
strlen ((const char *) tap_if->dev_name)));
- mp->context = context;
+ mp->rx_ring_sz = htons (tap_if->rx_ring_sz);
+ mp->tx_ring_sz = htons (tap_if->tx_ring_sz);
+ clib_memcpy (mp->host_mac_addr, tap_if->host_mac_addr, 6);
+ clib_memcpy (mp->host_if_name, tap_if->host_if_name,
+ MIN (ARRAY_LEN (mp->host_if_name) - 1,
+ strlen ((const char *) tap_if->host_if_name)));
+ clib_memcpy (mp->host_namespace, tap_if->host_namespace,
+ MIN (ARRAY_LEN (mp->host_namespace) - 1,
+ strlen ((const char *) tap_if->host_namespace)));
+ clib_memcpy (mp->host_bridge, tap_if->host_bridge,
+ MIN (ARRAY_LEN (mp->host_bridge) - 1,
+ strlen ((const char *) tap_if->host_bridge)));
+ if (tap_if->host_ip4_prefix_len)
+ clib_memcpy (&mp->host_ip4_addr, &tap_if->host_ip4_addr, 4);
+ mp->host_ip4_prefix_len = tap_if->host_ip4_prefix_len;
+ if (tap_if->host_ip6_prefix_len)
+ clib_memcpy (&mp->host_ip6_addr, &tap_if->host_ip6_addr, 16);
+ mp->host_ip6_prefix_len = tap_if->host_ip6_prefix_len;
+ mp->context = context;
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index d4ef6d836c5..df5fcf509b8 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -24,6 +24,8 @@
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/ip/ip4_packet.h>
+#include <vnet/ip/ip6_packet.h>
#include <vnet/devices/virtio/virtio.h>
#define foreach_virtio_tx_func_error \
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c
index f746ada7326..5ca06366cad 100644
--- a/src/vnet/devices/virtio/node.c
+++ b/src/vnet/devices/virtio/node.c
@@ -30,6 +30,8 @@
#include <vnet/ethernet/ethernet.h>
#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
+#include <vnet/ip/ip4_packet.h>
+#include <vnet/ip/ip6_packet.h>
#include <vnet/devices/virtio/virtio.h>
diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c
index 7418673bbd1..7829da6b1a1 100644
--- a/src/vnet/devices/virtio/virtio.c
+++ b/src/vnet/devices/virtio/virtio.c
@@ -28,6 +28,8 @@
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/ip/ip4_packet.h>
+#include <vnet/ip/ip6_packet.h>
#include <vnet/devices/virtio/virtio.h>
virtio_main_t virtio_main;
diff --git a/src/vnet/devices/virtio/virtio.h b/src/vnet/devices/virtio/virtio.h
index cb97df87121..079223d233e 100644
--- a/src/vnet/devices/virtio/virtio.h
+++ b/src/vnet/devices/virtio/virtio.h
@@ -103,8 +103,17 @@ typedef struct
u64 features, remote_features;
virtio_if_type_t type;
+ u16 tx_ring_sz;
+ u16 rx_ring_sz;
u8 *host_if_name;
u8 *net_ns;
+ u8 *host_bridge;
+ u8 host_mac_addr[6];
+ ip4_address_t host_ip4_addr;
+ u8 host_ip4_prefix_len;
+ ip6_address_t host_ip6_addr;
+ u8 host_ip6_prefix_len;
+
int ifindex;
} virtio_if_t;