Run clang-format on all files.
This commit is contained in:
12
lcpng.c
12
lcpng.c
@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
lcp_main_t lcp_main;
|
lcp_main_t lcp_main;
|
||||||
|
|
||||||
u8 *lcp_get_default_ns(void) {
|
u8 *
|
||||||
|
lcp_get_default_ns (void)
|
||||||
|
{
|
||||||
lcp_main_t *lcpm = &lcp_main;
|
lcp_main_t *lcpm = &lcp_main;
|
||||||
|
|
||||||
if (!lcpm->default_namespace || lcpm->default_namespace[0] == 0)
|
if (!lcpm->default_namespace || lcpm->default_namespace[0] == 0)
|
||||||
@ -31,7 +33,9 @@ u8 *lcp_get_default_ns(void) {
|
|||||||
return lcpm->default_namespace;
|
return lcpm->default_namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lcp_get_default_ns_fd(void) {
|
int
|
||||||
|
lcp_get_default_ns_fd (void)
|
||||||
|
{
|
||||||
lcp_main_t *lcpm = &lcp_main;
|
lcp_main_t *lcpm = &lcp_main;
|
||||||
|
|
||||||
return lcpm->default_ns_fd;
|
return lcpm->default_ns_fd;
|
||||||
@ -40,7 +44,9 @@ int lcp_get_default_ns_fd(void) {
|
|||||||
/*
|
/*
|
||||||
* ns is expected to be or look like a NUL-terminated C string.
|
* ns is expected to be or look like a NUL-terminated C string.
|
||||||
*/
|
*/
|
||||||
int lcp_set_default_ns(u8 *ns) {
|
int
|
||||||
|
lcp_set_default_ns (u8 *ns)
|
||||||
|
{
|
||||||
lcp_main_t *lcpm = &lcp_main;
|
lcp_main_t *lcpm = &lcp_main;
|
||||||
char *p;
|
char *p;
|
||||||
int len;
|
int len;
|
||||||
|
25
lcpng_if.api
25
lcpng_if.api
@ -134,9 +134,10 @@ autoendian define lcp_itf_pair_details
|
|||||||
string netns[32]; /* LCP_NS_LEN */
|
string netns[32]; /* LCP_NS_LEN */
|
||||||
};
|
};
|
||||||
|
|
||||||
service {
|
service
|
||||||
rpc lcp_itf_pair_get returns lcp_itf_pair_get_reply
|
{
|
||||||
stream lcp_itf_pair_details;
|
rpc lcp_itf_pair_get returns lcp_itf_pair_get_reply stream
|
||||||
|
lcp_itf_pair_details;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Replace end/begin
|
/** \brief Replace end/begin
|
||||||
@ -155,14 +156,17 @@ autoreply define lcp_itf_pair_replace_end
|
|||||||
/*
|
/*
|
||||||
* Linux-CP Error counters/messages
|
* Linux-CP Error counters/messages
|
||||||
*/
|
*/
|
||||||
counters linuxcp {
|
counters linuxcp
|
||||||
packets {
|
{
|
||||||
|
packets
|
||||||
|
{
|
||||||
severity info;
|
severity info;
|
||||||
type counter64;
|
type counter64;
|
||||||
units "packets";
|
units "packets";
|
||||||
description "ARP packets processed";
|
description "ARP packets processed";
|
||||||
};
|
};
|
||||||
copies {
|
copies
|
||||||
|
{
|
||||||
severity info;
|
severity info;
|
||||||
type counter64;
|
type counter64;
|
||||||
units "packets";
|
units "packets";
|
||||||
@ -170,9 +174,12 @@ counters linuxcp {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
paths {
|
paths
|
||||||
"/err/linux-cp-arp-phy" "linuxcp";
|
{
|
||||||
"/err/linux-cp-arp-host" "linuxcp";
|
"/err/linux-cp-arp-phy"
|
||||||
|
"linuxcp";
|
||||||
|
"/err/linux-cp-arp-host"
|
||||||
|
"linuxcp";
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -162,7 +162,8 @@ vl_api_lcp_itf_pair_get_t_handler (vl_api_lcp_itf_pair_get_t *mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vl_api_lcp_default_ns_set_t_handler(vl_api_lcp_default_ns_set_t *mp) {
|
vl_api_lcp_default_ns_set_t_handler (vl_api_lcp_default_ns_set_t *mp)
|
||||||
|
{
|
||||||
vl_api_lcp_default_ns_set_reply_t *rmp;
|
vl_api_lcp_default_ns_set_reply_t *rmp;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
@ -173,7 +174,8 @@ vl_api_lcp_default_ns_set_t_handler(vl_api_lcp_default_ns_set_t *mp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vl_api_lcp_default_ns_get_t_handler(vl_api_lcp_default_ns_get_t *mp) {
|
vl_api_lcp_default_ns_get_t_handler (vl_api_lcp_default_ns_get_t *mp)
|
||||||
|
{
|
||||||
vl_api_lcp_default_ns_get_reply_t *rmp;
|
vl_api_lcp_default_ns_get_reply_t *rmp;
|
||||||
vl_api_registration_t *reg;
|
vl_api_registration_t *reg;
|
||||||
char *ns;
|
char *ns;
|
||||||
|
@ -173,9 +173,10 @@ VLIB_CLI_COMMAND (lcp_auto_subint_command, static) = {
|
|||||||
.function = lcp_auto_subint_command_fn,
|
.function = lcp_auto_subint_command_fn,
|
||||||
};
|
};
|
||||||
|
|
||||||
static clib_error_t *lcp_default_netns_command_fn(vlib_main_t *vm,
|
static clib_error_t *
|
||||||
unformat_input_t *input,
|
lcp_default_netns_command_fn (vlib_main_t *vm, unformat_input_t *input,
|
||||||
vlib_cli_command_t *cmd) {
|
vlib_cli_command_t *cmd)
|
||||||
|
{
|
||||||
unformat_input_t _line_input, *line_input = &_line_input;
|
unformat_input_t _line_input, *line_input = &_line_input;
|
||||||
u8 *ns;
|
u8 *ns;
|
||||||
int r;
|
int r;
|
||||||
@ -186,7 +187,8 @@ static clib_error_t *lcp_default_netns_command_fn(vlib_main_t *vm,
|
|||||||
|
|
||||||
ns = 0;
|
ns = 0;
|
||||||
|
|
||||||
while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) {
|
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||||
|
{
|
||||||
if (unformat (line_input, "netns %s", &ns))
|
if (unformat (line_input, "netns %s", &ns))
|
||||||
;
|
;
|
||||||
else if (unformat (line_input, "clear netns"))
|
else if (unformat (line_input, "clear netns"))
|
||||||
|
@ -184,7 +184,8 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags)
|
|||||||
|
|
||||||
// Sync interface state changes into host
|
// Sync interface state changes into host
|
||||||
lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index));
|
lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index));
|
||||||
if (!lip) return NULL;
|
if (!lip)
|
||||||
|
return NULL;
|
||||||
LCP_IF_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip,
|
LCP_IF_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip,
|
||||||
flags);
|
flags);
|
||||||
|
|
||||||
|
@ -149,8 +149,10 @@ lcp_itf_pair_show (u32 phy_sw_if_index)
|
|||||||
lcp_itf_pair_t *
|
lcp_itf_pair_t *
|
||||||
lcp_itf_pair_get (u32 index)
|
lcp_itf_pair_get (u32 index)
|
||||||
{
|
{
|
||||||
if (!lcp_itf_pair_pool) return NULL;
|
if (!lcp_itf_pair_pool)
|
||||||
if (index == INDEX_INVALID) return NULL;
|
return NULL;
|
||||||
|
if (index == INDEX_INVALID)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return pool_elt_at_index (lcp_itf_pair_pool, index);
|
return pool_elt_at_index (lcp_itf_pair_pool, index);
|
||||||
}
|
}
|
||||||
@ -230,12 +232,14 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
|
|||||||
if (lipi != INDEX_INVALID)
|
if (lipi != INDEX_INVALID)
|
||||||
return VNET_API_ERROR_VALUE_EXIST;
|
return VNET_API_ERROR_VALUE_EXIST;
|
||||||
|
|
||||||
if (host_sw_if_index == ~0) {
|
if (host_sw_if_index == ~0)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid host");
|
LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid host");
|
||||||
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phy_sw_if_index == ~0) {
|
if (phy_sw_if_index == ~0)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid phy");
|
LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid phy");
|
||||||
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
||||||
}
|
}
|
||||||
@ -343,7 +347,8 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name)
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
sk = nl_socket_alloc ();
|
sk = nl_socket_alloc ();
|
||||||
if ((err = nl_connect (sk, NETLINK_ROUTE)) < 0) {
|
if ((err = nl_connect (sk, NETLINK_ROUTE)) < 0)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("netlink_add_link_vlan: Netlink connect error: %s",
|
LCP_IF_ERROR ("netlink_add_link_vlan: Netlink connect error: %s",
|
||||||
nl_geterror (err));
|
nl_geterror (err));
|
||||||
return clib_error_return (NULL, "Unable to connect socket: %d", err);
|
return clib_error_return (NULL, "Unable to connect socket: %d", err);
|
||||||
@ -356,7 +361,8 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name)
|
|||||||
rtnl_link_vlan_set_id (link, vlan);
|
rtnl_link_vlan_set_id (link, vlan);
|
||||||
rtnl_link_vlan_set_protocol (link, htons (proto));
|
rtnl_link_vlan_set_protocol (link, htons (proto));
|
||||||
|
|
||||||
if ((err = rtnl_link_add (sk, link, NLM_F_CREATE)) < 0) {
|
if ((err = rtnl_link_add (sk, link, NLM_F_CREATE)) < 0)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("netlink_add_link_vlan: Netlink link add error: %s",
|
LCP_IF_ERROR ("netlink_add_link_vlan: Netlink link add error: %s",
|
||||||
nl_geterror (err));
|
nl_geterror (err));
|
||||||
return clib_error_return (NULL, "Unable to add link %s: %d", name, err);
|
return clib_error_return (NULL, "Unable to add link %s: %d", name, err);
|
||||||
@ -611,7 +617,8 @@ lcp_itf_set_link_state (const lcp_itf_pair_t *lip, u8 state)
|
|||||||
vnet_main_t *vnm = vnet_get_main ();
|
vnet_main_t *vnm = vnet_get_main ();
|
||||||
int curr_ns_fd, vif_ns_fd;
|
int curr_ns_fd, vif_ns_fd;
|
||||||
|
|
||||||
if (!lip) return;
|
if (!lip)
|
||||||
|
return;
|
||||||
|
|
||||||
curr_ns_fd = vif_ns_fd = -1;
|
curr_ns_fd = vif_ns_fd = -1;
|
||||||
|
|
||||||
@ -769,12 +776,14 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
|
|||||||
const vnet_hw_interface_t *hw;
|
const vnet_hw_interface_t *hw;
|
||||||
lcp_itf_pair_t *lip;
|
lcp_itf_pair_t *lip;
|
||||||
|
|
||||||
if (!vnet_sw_if_index_is_api_valid (phy_sw_if_index)) {
|
if (!vnet_sw_if_index_is_api_valid (phy_sw_if_index))
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_create: Invalid phy index %u", phy_sw_if_index);
|
LCP_IF_ERROR ("pair_create: Invalid phy index %u", phy_sw_if_index);
|
||||||
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lcp_validate_if_name (host_if_name)) {
|
if (!lcp_validate_if_name (host_if_name))
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_create: Invalid host-if-name '%s'", host_if_name);
|
LCP_IF_ERROR ("pair_create: Invalid host-if-name '%s'", host_if_name);
|
||||||
return VNET_API_ERROR_INVALID_ARGUMENT;
|
return VNET_API_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
@ -782,13 +791,15 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
|
|||||||
vnm = vnet_get_main ();
|
vnm = vnet_get_main ();
|
||||||
sw = vnet_get_sw_interface (vnm, phy_sw_if_index);
|
sw = vnet_get_sw_interface (vnm, phy_sw_if_index);
|
||||||
hw = vnet_get_sup_hw_interface (vnm, phy_sw_if_index);
|
hw = vnet_get_sup_hw_interface (vnm, phy_sw_if_index);
|
||||||
if (!sw && !hw) {
|
if (!sw && !hw)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_create: Invalid interface");
|
LCP_IF_ERROR ("pair_create: Invalid interface");
|
||||||
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hw->hw_class_index != ethernet_hw_interface_class.index &&
|
if (hw->hw_class_index != ethernet_hw_interface_class.index &&
|
||||||
host_if_type == LCP_ITF_HOST_TAP) {
|
host_if_type == LCP_ITF_HOST_TAP)
|
||||||
|
{
|
||||||
LCP_IF_ERROR (
|
LCP_IF_ERROR (
|
||||||
"pair_create: don't create TAP for non-eth interface; use tun");
|
"pair_create: don't create TAP for non-eth interface; use tun");
|
||||||
return VNET_API_ERROR_INVALID_ARGUMENT;
|
return VNET_API_ERROR_INVALID_ARGUMENT;
|
||||||
@ -812,7 +823,9 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
|
|||||||
u16 vlan, proto;
|
u16 vlan, proto;
|
||||||
u32 parent_vif_index;
|
u32 parent_vif_index;
|
||||||
|
|
||||||
if (sw->type == VNET_SW_INTERFACE_TYPE_SUB && sw->sub.eth.flags.exact_match == 0) {
|
if (sw->type == VNET_SW_INTERFACE_TYPE_SUB &&
|
||||||
|
sw->sub.eth.flags.exact_match == 0)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_create: Cannot create LIP for a "
|
LCP_IF_ERROR ("pair_create: Cannot create LIP for a "
|
||||||
"sub-interface without exact-match set");
|
"sub-interface without exact-match set");
|
||||||
return VNET_API_ERROR_INVALID_ARGUMENT;
|
return VNET_API_ERROR_INVALID_ARGUMENT;
|
||||||
@ -821,7 +834,8 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
|
|||||||
outer_vlan = sw->sub.eth.outer_vlan_id;
|
outer_vlan = sw->sub.eth.outer_vlan_id;
|
||||||
inner_vlan = sw->sub.eth.inner_vlan_id;
|
inner_vlan = sw->sub.eth.inner_vlan_id;
|
||||||
outer_proto = inner_proto = ETH_P_8021Q;
|
outer_proto = inner_proto = ETH_P_8021Q;
|
||||||
if (1 == sw->sub.eth.flags.dot1ad) outer_proto = ETH_P_8021AD;
|
if (1 == sw->sub.eth.flags.dot1ad)
|
||||||
|
outer_proto = ETH_P_8021AD;
|
||||||
|
|
||||||
LCP_IF_INFO ("pair_create: creating dot1%s %d inner-dot1q %d on %U",
|
LCP_IF_INFO ("pair_create: creating dot1%s %d inner-dot1q %d on %U",
|
||||||
sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan,
|
sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan,
|
||||||
@ -916,7 +930,8 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
|
|||||||
|
|
||||||
err = lcp_netlink_add_link_vlan (parent_vif_index, vlan, proto,
|
err = lcp_netlink_add_link_vlan (parent_vif_index, vlan, proto,
|
||||||
(const char *) host_if_name);
|
(const char *) host_if_name);
|
||||||
if (err != 0) {
|
if (err != 0)
|
||||||
|
{
|
||||||
LCP_IF_ERROR ("pair_create: Cannot create link "
|
LCP_IF_ERROR ("pair_create: Cannot create link "
|
||||||
"outer(proto:0x%04x,vlan:%u).inner(proto:0x%"
|
"outer(proto:0x%04x,vlan:%u).inner(proto:0x%"
|
||||||
"04x,vlan:%u) name:'%s'",
|
"04x,vlan:%u) name:'%s'",
|
||||||
|
Reference in New Issue
Block a user