cleanup: Clean logging, consistent capitalization, nouns, and macro names

This commit is contained in:
Pim van Pelt
2023-01-11 16:18:18 +00:00
parent 2a218983d6
commit e53d4376ab
6 changed files with 129 additions and 122 deletions

View File

@ -58,7 +58,7 @@ lcp_itf_pair_sync_state (lcp_itf_pair_t *lip)
clib_setns (vif_ns_fd);
}
LCP_ITF_PAIR_INFO ("sync_state: %U flags %u sup-flags %u mtu %u sup-mtu %u",
LCP_IF_INFO ("sync_state: %U flags %u sup-flags %u mtu %u sup-mtu %u",
format_lcp_itf_pair, lip, sw->flags, sup_sw->flags,
sw->mtu[VNET_MTU_L3], sup_sw->mtu[VNET_MTU_L3]);
@ -69,7 +69,7 @@ lcp_itf_pair_sync_state (lcp_itf_pair_t *lip)
if (state && !(sup_sw->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
{
LCP_ITF_PAIR_WARN (
LCP_IF_WARN (
"sync_state: %U flags %u sup-flags %u mtu %u sup-mtu %u: "
"forcing state to sup-flags to satisfy netlink",
format_lcp_itf_pair, lip, sw->flags, sup_sw->flags,
@ -89,7 +89,7 @@ lcp_itf_pair_sync_state (lcp_itf_pair_t *lip)
if (sup_sw->mtu[VNET_MTU_L3] < sw->mtu[VNET_MTU_L3])
{
LCP_ITF_PAIR_WARN ("sync_state: %U flags %u mtu %u sup-mtu %u: "
LCP_IF_WARN ("sync_state: %U flags %u mtu %u sup-mtu %u: "
"clamping to sup-mtu to satisfy netlink",
format_lcp_itf_pair, lip, sw->flags,
sw->mtu[VNET_MTU_L3], sup_sw->mtu[VNET_MTU_L3]);
@ -163,7 +163,7 @@ lcp_itf_pair_sync_state_hw (vnet_hw_interface_t *hi)
{
if (!hi)
return;
LCP_ITF_PAIR_DBG ("sync_state_hw: hi %U", format_vnet_sw_if_index_name,
LCP_IF_DBG ("sync_state_hw: hi %U", format_vnet_sw_if_index_name,
vnet_get_main (), hi->hw_if_index);
vnet_hw_interface_walk_sw (vnet_get_main (), hi->hw_if_index,
@ -180,14 +180,14 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags)
if (!lcp_sync ())
return 0;
LCP_ITF_PAIR_DBG ("admin_state_change: sw %U %u",
LCP_IF_DBG ("admin_state_change: sw %U %u",
format_vnet_sw_if_index_name, vnm, sw_if_index,
flags);
// Sync interface state changes into host
lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index));
if (!lip) return NULL;
LCP_ITF_PAIR_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip, flags);
LCP_IF_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip, flags);
if (vnet_sw_interface_is_sub (vnm, sw_if_index))
{
@ -207,7 +207,7 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags)
hi = vnet_get_hw_interface_or_null (vnm, si->hw_if_index);
if (!hi)
return NULL;
LCP_ITF_PAIR_DBG ("admin_state_change: si %U hi %U, syncing children",
LCP_IF_DBG ("admin_state_change: si %U hi %U, syncing children",
format_vnet_sw_if_index_name, vnm, si->sw_if_index,
format_vnet_sw_if_index_name, vnm, hi->sw_if_index);
@ -226,7 +226,7 @@ lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags)
if (!lcp_sync ())
return NULL;
LCP_ITF_PAIR_DBG ("mtu_change: sw %U %u", format_vnet_sw_if_index_name, vnm,
LCP_IF_DBG ("mtu_change: sw %U %u", format_vnet_sw_if_index_name, vnm,
sw_if_index, flags);
if (vnet_sw_interface_is_sub (vnm, sw_if_index))
@ -250,7 +250,7 @@ lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags)
hi = vnet_get_hw_interface_or_null (vnm, si->hw_if_index);
if (!hi)
return NULL;
LCP_ITF_PAIR_DBG ("mtu_change: si %U hi %U, syncing children",
LCP_IF_DBG ("mtu_change: si %U hi %U, syncing children",
format_vnet_sw_if_index_name, vnm, si->sw_if_index,
format_vnet_sw_if_index_name, vnm, hi->sw_if_index);
@ -411,7 +411,7 @@ lcp_itf_ip4_add_del_interface_addr (ip4_main_t *im, uword opaque,
if (!lcp_sync ())
return;
LCP_ITF_PAIR_DBG ("ip4_addr_%s: si:%U %U/%u", is_del ? "del" : "add",
LCP_IF_DBG ("ip4_addr_%s: si:%U %U/%u", is_del ? "del" : "add",
format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index, format_ip4_address, address, address_length);
@ -427,7 +427,7 @@ lcp_itf_ip4_add_del_interface_addr (ip4_main_t *im, uword opaque,
clib_setns (vif_ns_fd);
}
LCP_ITF_PAIR_DBG ("ip4_addr_%s: %U ip4 %U/%u", is_del ? "del" : "add",
LCP_IF_DBG ("ip4_addr_%s: %U ip4 %U/%u", is_del ? "del" : "add",
format_lcp_itf_pair, lip, format_ip4_address, address,
address_length);
@ -460,7 +460,7 @@ lcp_itf_ip6_add_del_interface_addr (ip6_main_t *im, uword opaque,
if (!lcp_sync ())
return;
LCP_ITF_PAIR_DBG ("ip6_addr_%s: si:%U %U/%u", is_del ? "del" : "add",
LCP_IF_DBG ("ip6_addr_%s: si:%U %U/%u", is_del ? "del" : "add",
format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index, format_ip6_address, address, address_length);
@ -475,7 +475,7 @@ lcp_itf_ip6_add_del_interface_addr (ip6_main_t *im, uword opaque,
if (vif_ns_fd != -1)
clib_setns (vif_ns_fd);
}
LCP_ITF_PAIR_DBG ("ip6_addr_%s: %U ip4 %U/%u", is_del ? "del" : "add",
LCP_IF_DBG ("ip6_addr_%s: %U ip4 %U/%u", is_del ? "del" : "add",
format_lcp_itf_pair, lip, format_ip6_address, address,
address_length);
if (is_del)
@ -509,7 +509,7 @@ lcp_itf_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
if (!is_sub)
return NULL;
LCP_ITF_PAIR_DBG ("interface_%s: sw %U parent %U", is_create ? "add" : "del",
LCP_IF_DBG ("interface_%s: sw %U parent %U", is_create ? "add" : "del",
format_vnet_sw_if_index_name, vnet_get_main (),
sw->sw_if_index, format_vnet_sw_if_index_name,
vnet_get_main (), sw->sup_sw_if_index);
@ -527,7 +527,7 @@ lcp_itf_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
name = format (name, "%s.%d", sup_lip->lip_host_name, sw->sub.id);
LCP_ITF_PAIR_INFO (
LCP_IF_INFO (
"interface_%s: %U has parent %U, auto-creating LCP with host-if %s",
is_create ? "add" : "del", format_vnet_sw_if_index_name,
vnet_get_main (), sw->sw_if_index, format_lcp_itf_pair, sup_lip, name);

View File

@ -231,17 +231,17 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
return VNET_API_ERROR_VALUE_EXIST;
if (host_sw_if_index == ~0) {
LCP_ITF_PAIR_ERR ("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;
}
if (phy_sw_if_index == ~0) {
LCP_ITF_PAIR_ERR ("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;
}
LCP_ITF_PAIR_NOTICE (
"pair_add: Adding LIP for host:%U phy:%U, host_if:%v vif:%d ns:%v",
LCP_IF_NOTICE (
"pair_add: Adding LIP for host:%U phy:%U host_if:%v vif:%d netns:%v",
format_vnet_sw_if_index_name, vnet_get_main (), host_sw_if_index,
format_vnet_sw_if_index_name, vnet_get_main (), phy_sw_if_index, host_name,
host_index, ns);
@ -344,8 +344,9 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name)
sk = nl_socket_alloc ();
if ((err = nl_connect (sk, NETLINK_ROUTE)) < 0) {
LCP_ITF_PAIR_ERR ("netlink_add_link_vlan: connect error: %s", nl_geterror(err));
return clib_error_return (NULL, "Unable to connect socket: %d", err);
LCP_IF_ERROR ("netlink_add_link_vlan: Netlink connect error: %s",
nl_geterror (err));
return clib_error_return (NULL, "Unable to connect socket: %d", err);
}
link = rtnl_link_vlan_alloc ();
@ -356,8 +357,9 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name)
rtnl_link_vlan_set_protocol (link, htons (proto));
if ((err = rtnl_link_add (sk, link, NLM_F_CREATE)) < 0) {
LCP_ITF_PAIR_ERR ("netlink_add_link_vlan: link add error: %s", nl_geterror(err));
return clib_error_return (NULL, "Unable to add link %s: %d", name, err);
LCP_IF_ERROR ("netlink_add_link_vlan: Netlink link add error: %s",
nl_geterror (err));
return clib_error_return (NULL, "Unable to add link %s: %d", name, err);
}
rtnl_link_put (link);
@ -404,8 +406,8 @@ lcp_itf_pair_del (u32 phy_sw_if_index)
lip = lcp_itf_pair_get (lipi);
LCP_ITF_PAIR_NOTICE (
"pair_del: host:%U phy:%U host_if:%v vif:%d ns:%v",
LCP_IF_NOTICE (
"pair_del: Deleting LIP for host:%U phy:%U host_if:%v vif:%d netns:%v",
format_vnet_sw_if_index_name, vnet_get_main (), lip->lip_host_sw_if_index,
format_vnet_sw_if_index_name, vnet_get_main (), lip->lip_phy_sw_if_index,
lip->lip_host_name, lip->lip_vif_index, lip->lip_namespace);
@ -671,7 +673,7 @@ lcp_itf_set_interface_addr (const lcp_itf_pair_t *lip)
foreach_ip_interface_address (
lm4, ia, lip->lip_phy_sw_if_index, 1 /* honor unnumbered */, ({
ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
LCP_ITF_PAIR_NOTICE ("set_interface_addr: %U add ip4 %U/%d",
LCP_IF_NOTICE ("set_interface_addr: %U add ip4 %U/%d",
format_lcp_itf_pair, lip, format_ip4_address, r4,
ia->address_length);
vnet_netlink_add_ip4_addr (lip->lip_vif_index, r4, ia->address_length);
@ -681,7 +683,7 @@ lcp_itf_set_interface_addr (const lcp_itf_pair_t *lip)
foreach_ip_interface_address (
lm6, ia, lip->lip_phy_sw_if_index, 1 /* honor unnumbered */, ({
ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
LCP_ITF_PAIR_NOTICE ("set_interface_addr: %U add ip6 %U/%d",
LCP_IF_NOTICE ("set_interface_addr: %U add ip6 %U/%d",
format_lcp_itf_pair, lip, format_ip6_address, r6,
ia->address_length);
vnet_netlink_add_ip6_addr (lip->lip_vif_index, r6, ia->address_length);
@ -717,7 +719,7 @@ lcp_itf_pair_find_walk (vnet_main_t *vnm, u32 sw_if_index, void *arg)
(sw->sub.eth.outer_vlan_id == match->vlan) &&
(sw->sub.eth.flags.dot1ad == match->dot1ad))
{
LCP_ITF_PAIR_DBG ("find_walk: found match outer %d dot1ad %d "
LCP_IF_DBG ("find_walk: found match outer %d dot1ad %d "
"inner-dot1q %d: interface %U",
sw->sub.eth.outer_vlan_id, sw->sub.eth.flags.dot1ad,
sw->sub.eth.inner_vlan_id,
@ -769,21 +771,22 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
lcp_itf_pair_t *lip;
if (!vnet_sw_if_index_is_api_valid (phy_sw_if_index)) {
LCP_ITF_PAIR_ERR ("pair_create: invalid phy index %u", phy_sw_if_index);
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
LCP_IF_ERROR ("pair_create: Invalid phy index %u", phy_sw_if_index);
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
}
if (!lcp_validate_if_name (host_if_name)) {
LCP_ITF_PAIR_ERR ("pair_create: invalid host-if-name '%s'", host_if_name);
return VNET_API_ERROR_INVALID_ARGUMENT;
LCP_IF_ERROR ("pair_create: Invalid host-if-name '%s'",
host_if_name);
return VNET_API_ERROR_INVALID_ARGUMENT;
}
vnm = vnet_get_main ();
sw = vnet_get_sw_interface (vnm, phy_sw_if_index);
hw = vnet_get_sup_hw_interface (vnm, phy_sw_if_index);
if (!sw && !hw) {
LCP_ITF_PAIR_ERR ("pair_create: invalid interface");
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
LCP_IF_ERROR ("pair_create: Invalid interface");
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
}
@ -806,8 +809,9 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
u32 parent_vif_index;
if (sw->type == VNET_SW_INTERFACE_TYPE_SUB && sw->sub.eth.flags.exact_match == 0) {
LCP_ITF_PAIR_ERR ("pair_create: can't create LCP for a sub-interface without exact-match set");
return VNET_API_ERROR_INVALID_ARGUMENT;
LCP_IF_ERROR ("pair_create: Cannot create LIP for a "
"sub-interface without exact-match set");
return VNET_API_ERROR_INVALID_ARGUMENT;
}
outer_vlan = sw->sub.eth.outer_vlan_id;
@ -815,7 +819,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
outer_proto = inner_proto = ETH_P_8021Q;
if (1 == sw->sub.eth.flags.dot1ad) outer_proto = ETH_P_8021AD;
LCP_ITF_PAIR_INFO (
LCP_IF_INFO (
"pair_create: creating dot1%s %d inner-dot1q %d on %U",
sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan, inner_vlan,
format_vnet_sw_if_index_name, vnet_get_main (), hw->sw_if_index);
@ -823,7 +827,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
parent_if_index = lcp_itf_pair_find_by_phy (sw->sup_sw_if_index);
if (INDEX_INVALID == parent_if_index)
{
LCP_ITF_PAIR_ERR ("pair_create: can't find LCP for %U",
LCP_IF_ERROR ("pair_create: Cannot find LIP for %U",
format_vnet_sw_if_index_name, vnet_get_main (),
sw->sup_sw_if_index);
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
@ -831,11 +835,11 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
lip = lcp_itf_pair_get (parent_if_index);
if (!lip)
{
LCP_ITF_PAIR_ERR ("pair_create: can't create LCP for a "
LCP_IF_ERROR ("pair_create: Cannot create LIP for a "
"sub-interface without an LCP on the parent");
return VNET_API_ERROR_INVALID_ARGUMENT;
}
LCP_ITF_PAIR_DBG ("pair_create: parent %U", format_lcp_itf_pair, lip);
LCP_IF_DBG ("pair_create: parent %U", format_lcp_itf_pair, lip);
parent_vif_index = lip->lip_vif_index;
/*
@ -879,11 +883,11 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
sw->sub.eth.flags.dot1ad);
if (INDEX_INVALID == linux_parent_if_index)
{
LCP_ITF_PAIR_ERR ("pair_create: can't find LCP for outer "
LCP_IF_ERROR ("pair_create: Cannot find LIP for outer "
"vlan %d proto %s on %U",
outer_vlan,
outer_proto == ETH_P_8021AD ? "dot1ad" :
"dot1q",
"dot1q",
format_vnet_sw_if_index_name,
vnet_get_main (), hw->sw_if_index);
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
@ -891,13 +895,13 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
llip = lcp_itf_pair_get (linux_parent_if_index);
if (!llip)
{
LCP_ITF_PAIR_ERR (
"pair_create: can't create LCP for a "
LCP_IF_ERROR (
"pair_create: Cannot create LIP for a "
"sub-interface without a valid Linux parent");
return VNET_API_ERROR_INVALID_ARGUMENT;
}
LCP_ITF_PAIR_DBG ("pair_create: linux parent %U",
LCP_IF_DBG ("pair_create: linux parent %U",
format_lcp_itf_pair, llip);
parent_vif_index = llip->lip_vif_index;
}
@ -910,8 +914,11 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
err = lcp_netlink_add_link_vlan (parent_vif_index, vlan, proto,
(const char *) host_if_name);
if (err != 0) {
LCP_ITF_PAIR_ERR ("pair_create: cannot create link outer(proto:0x%04x,vlan:%u).inner(proto:0x%04x,vlan:%u) name:'%s'",
outer_proto, outer_vlan, inner_proto, inner_vlan, host_if_name);
LCP_IF_ERROR ("pair_create: Cannot create link "
"outer(proto:0x%04x,vlan:%u).inner(proto:0x%"
"04x,vlan:%u) name:'%s'",
outer_proto, outer_vlan, inner_proto,
inner_vlan, host_if_name);
}
if (!err)
@ -926,7 +933,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
sw->sub.eth.raw_flags, inner_vlan,
outer_vlan, &host_sw_if_index))
{
LCP_ITF_PAIR_ERR (
LCP_IF_ERROR (
"pair_create: failed to create tap subint: %d.%d on %U",
outer_vlan, inner_vlan, format_vnet_sw_if_index_name,
vnet_get_main (), lip->lip_host_sw_if_index);
@ -997,7 +1004,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
tap_create_if (vm, &args);
if (args.rv < 0)
{
LCP_ITF_PAIR_ERR ("pair_create: could not create tap, retval:%d",
LCP_IF_ERROR ("pair_create: Cannot create TAP: retval:%d",
args.rv);
clib_error_free (args.error);
return args.rv;
@ -1028,7 +1035,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
if (!vif_index)
{
LCP_ITF_PAIR_ERR (
LCP_IF_ERROR (
"pair_create: failed pair add (no vif index): {%U, %U, %s}",
format_vnet_sw_if_index_name, vnet_get_main (), phy_sw_if_index,
format_vnet_sw_if_index_name, vnet_get_main (), host_sw_if_index,

View File

@ -23,19 +23,19 @@
extern vlib_log_class_t lcp_itf_pair_logger;
#define LCP_ITF_PAIR_DBG(...) \
#define LCP_IF_DBG(...) \
vlib_log_debug (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_INFO(...) \
#define LCP_IF_INFO(...) \
vlib_log_info (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_NOTICE(...) \
#define LCP_IF_NOTICE(...) \
vlib_log_notice (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_WARN(...) \
#define LCP_IF_WARN(...) \
vlib_log_warn (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_ERR(...) \
#define LCP_IF_ERROR(...) \
vlib_log_err (lcp_itf_pair_logger, __VA_ARGS__);

View File

@ -231,7 +231,7 @@ lcp_nl_dispatch (struct nl_object *obj, void *arg)
lcp_nl_route_del ((struct rtnl_route *) obj);
break;
default:
NL_WARN ("dispatch: ignored %U", format_nl_object, obj);
LCP_NL_WARN ("dispatch: Ignored %U", format_nl_object, obj);
break;
}
vlib_worker_thread_barrier_release (vlib_get_main ());
@ -267,20 +267,20 @@ lcp_nl_process_msgs (void)
vec_foreach (msg_info, nm->nl_ns.nl_msg_queue)
{
if ((err = nl_msg_parse (msg_info->msg, lcp_nl_dispatch, msg_info)) < 0)
NL_ERROR ("process_msgs: Unable to parse object: %s",
LCP_NL_ERROR ("process_msgs: Unable to parse object: %s",
nl_geterror (err));
nlmsg_free (msg_info->msg);
if (++n_msgs >= nm->batch_size)
{
NL_INFO ("process_msgs: batch_size %u reached, yielding",
LCP_NL_INFO ("process_msgs: batch_size %u reached, yielding",
nm->batch_size);
break;
}
usecs = (u64) (1e6 * (vlib_time_now (vlib_get_main ()) - start));
if (usecs >= 1e3 * nm->batch_work_ms)
{
NL_INFO ("process_msgs: batch_work_ms %u reached, yielding",
LCP_NL_INFO ("process_msgs: batch_work_ms %u reached, yielding",
nm->batch_work_ms);
break;
}
@ -294,13 +294,13 @@ lcp_nl_process_msgs (void)
{
if (vec_len (nm->nl_ns.nl_msg_queue))
{
NL_WARN ("process_msgs: Processed %u messages in %llu usecs, %u "
LCP_NL_WARN ("process_msgs: Processed %u messages in %llu usecs, %u "
"left in queue",
n_msgs, usecs, vec_len (nm->nl_ns.nl_msg_queue));
}
else
{
NL_DBG ("process_msgs: Processed %u messages in %llu usecs", n_msgs,
LCP_NL_DBG ("process_msgs: Processed %u messages in %llu usecs", n_msgs,
usecs);
}
}
@ -348,7 +348,7 @@ lcp_nl_process (vlib_main_t *vm, vlib_node_runtime_t *node,
break;
default:
NL_ERROR ("process: Unknown event type: %u", (u32) event_type);
LCP_NL_ERROR ("process: Unknown event type: %u", (u32) event_type);
}
vec_reset_length (event_data);
@ -399,13 +399,13 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip)
// In future work, this plugin should be able to maintain a list of
// namespaces to listen on, adding/deleting listeners dynamically, ie every
// time this callback is invoked.
NL_DBG ("pair_add_cb: %U refcnt %u", format_lcp_itf_pair, lip,
LCP_NL_DBG ("pair_add_cb: %U refcnt %u", format_lcp_itf_pair, lip,
nm->nl_ns.clib_file_lcp_refcnt);
if ((nm->nl_ns.clib_file_lcp_refcnt > 0) &&
vec_cmp(nm->nl_ns.netns_name, lip->lip_namespace))
{
NL_WARN ("pair_add_cb: Existing netlink listener for netns %v -- this "
LCP_NL_WARN ("pair_add_cb: Existing netlink listener for netns %v -- this "
"itf-pair is in netns %v, will not be listened!",
nm->nl_ns.netns_name, lip->lip_namespace);
return;
@ -414,7 +414,7 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip)
nm->nl_ns.clib_file_lcp_refcnt++;
if (nm->nl_ns.clib_file_index == ~0)
{
NL_INFO ("pair_add_cb: Adding netlink listener for netns %v",
LCP_NL_INFO ("pair_add_cb: Adding netlink listener for netns %v",
lip->lip_namespace);
lcp_nl_open_socket (lip->lip_namespace);
}
@ -426,13 +426,13 @@ lcp_nl_pair_del_cb (lcp_itf_pair_t *lip)
lcp_nl_main_t *nm = &lcp_nl_main;
// See NOTE in lcp_nl_pair_add_cb().
NL_DBG ("pair_del_cb: %U refcnt %u", format_lcp_itf_pair, lip,
LCP_NL_DBG ("pair_del_cb: %U refcnt %u", format_lcp_itf_pair, lip,
nm->nl_ns.clib_file_lcp_refcnt);
nm->nl_ns.clib_file_lcp_refcnt--;
if (nm->nl_ns.clib_file_lcp_refcnt == 0)
{
NL_INFO ("pair_del_cb: Removing netlink listener for netns %v",
LCP_NL_INFO ("pair_del_cb: Removing netlink listener for netns %v",
lip->lip_namespace);
lcp_nl_close_socket ();
return;
@ -457,7 +457,7 @@ lcp_nl_read_cb (clib_file_t *f)
;
if (err < 0 && err != -NLE_AGAIN)
{
NL_ERROR ("read_cb: Error reading netlink socket (fd %d): %s (%d)",
LCP_NL_ERROR ("read_cb: Error reading netlink socket (fd %d): %s (%d)",
f->file_descriptor, nl_geterror (err), err);
vlib_process_signal_event (vlib_get_main (), lcp_nl_process_node.index,
NL_EVENT_READ_ERR, 0);
@ -475,7 +475,7 @@ lcp_nl_read_cb (clib_file_t *f)
static clib_error_t *
lcp_nl_error_cb (clib_file_t *f)
{
NL_ERROR ("error_cb: Error polling netlink socket (fd %d)",
LCP_NL_ERROR ("error_cb: Error polling netlink socket (fd %d)",
f->file_descriptor);
/* notify process node */
@ -499,7 +499,7 @@ lcp_nl_close_socket (void)
if (f)
{
NL_DBG ("close_socket: Stopping poll of netlink fd %u",
LCP_NL_DBG ("close_socket: Stopping poll of netlink fd %u",
f->file_descriptor);
fm->file_update (f, UNIX_FILE_UPDATE_DELETE);
}
@ -509,7 +509,7 @@ lcp_nl_close_socket (void)
/* If we created a socket, close/free it */
if (nm->nl_ns.sk_route)
{
NL_DBG ("close_socket: Closing netlink socket %d",
LCP_NL_DBG ("close_socket: Closing netlink socket %d",
nl_socket_get_fd (nm->nl_ns.sk_route));
nl_socket_free (nm->nl_ns.sk_route);
nm->nl_ns.sk_route = NULL;
@ -562,7 +562,7 @@ lcp_nl_open_socket (u8 *ns)
nm->tx_buf_size);
if (err != 0)
{
NL_ERROR ("open_socket: Failed to set buffer size tx %u rx %u error %s",
LCP_NL_ERROR ("open_socket: Failed to set buffer size tx %u rx %u error %s",
nm->tx_buf_size, nm->rx_buf_size, nl_geterror (err));
}
@ -586,7 +586,7 @@ lcp_nl_open_socket (u8 *ns)
};
nm->nl_ns.clib_file_index = clib_file_add (&file_main, &rt_file);
NL_DBG ("open_socket: Added netlink file idx %u fd %u ns %s",
LCP_NL_DBG ("open_socket: Added netlink file idx %u fd %u netns %s",
nm->nl_ns.clib_file_index, rt_file.file_descriptor, ns);
}
else
@ -597,13 +597,13 @@ lcp_nl_open_socket (u8 *ns)
f->file_descriptor = nl_socket_get_fd (nm->nl_ns.sk_route);
fm->file_update (f, UNIX_FILE_UPDATE_ADD);
NL_DBG ("open_socket: Updated netlink file idx %u fd %u ns %s",
LCP_NL_DBG ("open_socket: Updated netlink file idx %u fd %u netns %s",
nm->nl_ns.clib_file_index, f->file_descriptor, ns);
}
nl_socket_modify_cb (nm->nl_ns.sk_route, NL_CB_VALID, NL_CB_CUSTOM,
lcp_nl_callback, NULL);
NL_NOTICE ("open_socket: Started poll of netlink fd %d ns %s",
LCP_NL_NOTICE ("open_socket: Started poll of netlink fd %d netns %s",
nl_socket_get_fd (nm->nl_ns.sk_route), nm->nl_ns.netns_name);
}

View File

@ -40,11 +40,11 @@ typedef enum nl_event_type_t_
#define NL_BATCH_WORK_MS_DEF 40 /* 40 ms */
#define NL_BATCH_DELAY_MS_DEF 10 /* 10 ms, max 20 batch/s */
#define NL_DBG(...) vlib_log_debug (lcp_nl_main.nl_logger, __VA_ARGS__);
#define NL_INFO(...) vlib_log_info (lcp_nl_main.nl_logger, __VA_ARGS__);
#define NL_NOTICE(...) vlib_log_notice (lcp_nl_main.nl_logger, __VA_ARGS__);
#define NL_WARN(...) vlib_log_warn (lcp_nl_main.nl_logger, __VA_ARGS__);
#define NL_ERROR(...) vlib_log_err (lcp_nl_main.nl_logger, __VA_ARGS__);
#define LCP_NL_DBG(...) vlib_log_debug (lcp_nl_main.nl_logger, __VA_ARGS__);
#define LCP_NL_INFO(...) vlib_log_info (lcp_nl_main.nl_logger, __VA_ARGS__);
#define LCP_NL_NOTICE(...) vlib_log_notice (lcp_nl_main.nl_logger, __VA_ARGS__);
#define LCP_NL_WARN(...) vlib_log_warn (lcp_nl_main.nl_logger, __VA_ARGS__);
#define LCP_NL_ERROR(...) vlib_log_err (lcp_nl_main.nl_logger, __VA_ARGS__);
/* struct type to hold context on the netlink message being processed.
*/

View File

@ -246,7 +246,7 @@ lcp_nl_route_path_parse (struct rtnl_nexthop *rnh, void *arg)
if (ctx->is_mcast)
path->frp_mitf_flags = MFIB_ITF_FLAG_FORWARD;
NL_DBG ("route_path_parse: path %U", format_fib_route_path, path);
LCP_NL_DBG ("route_path_parse: path %U", format_fib_route_path, path);
}
/*
@ -273,7 +273,7 @@ lcp_nl_route_path_add_special (struct rtnl_route *rr,
path->frp_proto = fib_proto_to_dpo (ctx->route_proto);
path->frp_preference = ctx->preference;
NL_DBG ("route_path_add_special: path %U", format_fib_route_path, path);
LCP_NL_DBG ("route_path_add_special: path %U", format_fib_route_path, path);
}
static lcp_nl_table_t *
@ -403,7 +403,7 @@ lcp_nl_route_del (struct rtnl_route *rr)
lcp_nl_table_t *nlt;
uint8_t rtype, rproto;
NL_DBG ("route_del: netlink %U", format_nl_object, rr);
LCP_NL_DBG ("route_del: netlink %U", format_nl_object, rr);
rtype = rtnl_route_get_type (rr);
table_id = rtnl_route_get_table (rr);
@ -435,7 +435,7 @@ lcp_nl_route_del (struct rtnl_route *rr)
fib_entry_flag_t entry_flags;
entry_flags = lcp_nl_mk_route_entry_flags (rtype, table_id, rproto);
NL_INFO ("route_del: table %d prefix %U flags %U",
LCP_NL_INFO ("route_del: table %d prefix %U flags %U",
rtnl_route_get_table (rr), format_fib_prefix, &pfx,
format_fib_entry_flags, entry_flags);
if (pfx.fp_proto == FIB_PROTOCOL_IP6)
@ -459,7 +459,7 @@ lcp_nl_route_add (struct rtnl_route *rr)
lcp_nl_table_t *nlt;
uint8_t rtype, rproto;
NL_DBG ("route_add: netlink %U", format_nl_object, rr);
LCP_NL_DBG ("route_add: netlink %U", format_nl_object, rr);
rtype = rtnl_route_get_type (rr);
table_id = rtnl_route_get_table (rr);
@ -479,7 +479,7 @@ lcp_nl_route_add (struct rtnl_route *rr)
(ip6_address_is_multicast (&pfx.fp_addr.ip6) ||
ip6_address_is_link_local_unicast (&pfx.fp_addr.ip6))))
{
NL_DBG ("route_add: skip linklocal table %d prefix %U flags %U",
LCP_NL_DBG ("route_add: skip linklocal table %d prefix %U flags %U",
rtnl_route_get_table (rr), format_fib_prefix, &pfx,
format_fib_entry_flags, entry_flags);
return;
@ -504,7 +504,7 @@ lcp_nl_route_add (struct rtnl_route *rr)
lcp_nl_mk_route_mprefix (rr, &mpfx);
NL_INFO ("route_add: mcast table %d prefix %U flags %U",
LCP_NL_INFO ("route_add: mcast table %d prefix %U flags %U",
rtnl_route_get_table (rr), format_mfib_prefix, &mpfx,
format_fib_entry_flags, entry_flags);
mfib_table_entry_update (nlt->nlt_mfib_index, &mpfx,
@ -530,7 +530,7 @@ lcp_nl_route_add (struct rtnl_route *rr)
}
fib_src = lcp_nl_proto_fib_source (rproto);
NL_INFO ("route_add: table %d prefix %U flags %U",
LCP_NL_INFO ("route_add: table %d prefix %U flags %U",
rtnl_route_get_table (rr), format_fib_prefix, &pfx,
format_fib_entry_flags, entry_flags);
@ -543,7 +543,7 @@ lcp_nl_route_add (struct rtnl_route *rr)
}
}
else
NL_WARN ("route_add: no paths table %d prefix %U flags %U netlink %U",
LCP_NL_WARN ("route_add: No paths table %d prefix %U flags %U netlink %U",
rtnl_route_get_table (rr), format_fib_prefix, &pfx,
format_fib_entry_flags, entry_flags, format_nl_object, rr);
@ -579,14 +579,14 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl)
*/
if (!(parent_lip = lcp_itf_pair_get (lcp_itf_pair_find_by_vif (parent_idx))))
{
NL_WARN ("link_add_vlan: no LCP for parent of %U", format_nl_object, rl);
LCP_NL_WARN ("link_add_vlan: No LIP for parent of %U", format_nl_object, rl);
return NULL;
}
parent_sw = vnet_get_sw_interface (vnm, parent_lip->lip_phy_sw_if_index);
if (!parent_sw)
{
NL_ERROR ("link_add_vlan: Cannot get parent of %U", format_lcp_itf_pair,
LCP_NL_ERROR ("link_add_vlan: Cannot get parent of %U", format_lcp_itf_pair,
parent_lip);
return NULL;
}
@ -603,7 +603,7 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl)
outer_vlan = parent_sw->sub.eth.outer_vlan_id;
if (ntohs (proto) == ETH_P_8021AD)
{
NL_ERROR ("link_add_vlan: cannot create inner dot1ad: %U",
LCP_NL_ERROR ("link_add_vlan: Cannot create inner dot1ad: %U",
format_nl_object, rl);
return NULL;
}
@ -634,20 +634,20 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl)
if (vnet_sw_interface_get_available_subid (vnm, parent_sw->sup_sw_if_index,
&subid))
{
NL_ERROR ("link_add_vlan: cannot find available subid on phy %U",
LCP_NL_ERROR ("link_add_vlan: Cannot find available subid on phy %U",
format_vnet_sw_if_index_name, vnm, parent_sw->sup_sw_if_index);
lcpm->lcp_auto_subint = old_lcp_auto_subint;
return NULL;
}
NL_INFO (
"link_add_vlan: creating subid %u outer %u inner %u flags %u on phy %U",
LCP_NL_INFO (
"link_add_vlan: Creating subid %u outer %u inner %u flags %u on phy %U",
subid, outer_vlan, inner_vlan, flags, format_vnet_sw_if_index_name, vnm,
parent_sw->sup_sw_if_index);
if (vnet_create_sub_interface (parent_sw->sup_sw_if_index, subid, flags,
inner_vlan, outer_vlan, &phy_sw_if_index))
{
NL_ERROR ("link_add_vlan: cannot create sub-int on phy %U flags %u "
LCP_NL_ERROR ("link_add_vlan: Cannot create sub-int on phy %U flags %u "
"inner-dot1q %u dot1%s %u",
format_vnet_sw_if_index_name, vnm, parent_sw->sup_sw_if_index,
flags, inner_vlan,
@ -662,13 +662,13 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl)
vnet_sw_interface_get_available_subid (
vnm, phy_lip->lip_host_sw_if_index, &subid))
{
NL_ERROR ("link_add_vlan: cannot find available subid on host %U",
LCP_NL_ERROR ("link_add_vlan: Cannot find available subid on host %U",
format_vnet_sw_if_index_name, vnm,
phy_lip->lip_host_sw_if_index);
lcpm->lcp_auto_subint = old_lcp_auto_subint;
return NULL;
}
NL_INFO ("link_add_vlan: creating subid %u outer %u inner %u flags %u on "
LCP_NL_INFO ("link_add_vlan: creating subid %u outer %u inner %u flags %u on "
"host %U phy %U",
subid, outer_vlan, inner_vlan, flags,
format_vnet_sw_if_index_name, vnm,
@ -678,7 +678,7 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl)
if (vnet_create_sub_interface (phy_lip->lip_host_sw_if_index, subid, flags,
inner_vlan, outer_vlan, &host_sw_if_index))
{
NL_ERROR ("link_add_vlan: cannot create sub-int on host %U flags %u "
LCP_NL_ERROR ("link_add_vlan: Cannot create sub-int on host %U flags %u "
"inner-dot1q %u dot1%s %u",
format_vnet_sw_if_index_name, vnm,
phy_lip->lip_host_sw_if_index, flags, inner_vlan,
@ -688,7 +688,7 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl)
}
// Always keep sub-int on the TAP up
vnet_sw_interface_admin_up (vnm, host_sw_if_index);
NL_NOTICE ("link_add_vlan: Creating LCP for host %U phy %U name %s idx %d",
LCP_NL_NOTICE ("link_add_vlan: Creating LIP for host %U phy %U name %s idx %d",
format_vnet_sw_if_index_name, vnm, host_sw_if_index,
format_vnet_sw_if_index_name, vnm, phy_sw_if_index,
rtnl_link_get_name (rl), idx);
@ -712,21 +712,21 @@ lcp_nl_link_del (struct rtnl_link *rl)
{
lcp_itf_pair_t *lip;
NL_DBG ("link_del: netlink %U", format_nl_object, rl);
LCP_NL_DBG ("link_del: netlink %U", format_nl_object, rl);
if (!(lip = lcp_itf_pair_get (
lcp_itf_pair_find_by_vif (rtnl_link_get_ifindex (rl)))))
{
NL_WARN ("link_del: no LCP for %U ", format_nl_object, rl);
LCP_NL_WARN ("link_del: No LIP for %U ", format_nl_object, rl);
return;
}
NL_NOTICE ("link_del: Removing %U", format_lcp_itf_pair, lip);
LCP_NL_NOTICE ("link_del: Removing %U", format_lcp_itf_pair, lip);
lcp_itf_pair_delete (lip->lip_phy_sw_if_index);
if (rtnl_link_is_vlan (rl))
{
NL_NOTICE ("link_del: Removing subint %U", format_vnet_sw_if_index_name,
LCP_NL_NOTICE ("link_del: Removing subint %U", format_vnet_sw_if_index_name,
vnet_get_main (), lip->lip_phy_sw_if_index);
vnet_delete_sub_interface (lip->lip_phy_sw_if_index);
vnet_delete_sub_interface (lip->lip_host_sw_if_index);
@ -801,7 +801,7 @@ lcp_nl_link_add (struct rtnl_link *rl, void *ctx)
lcp_itf_pair_t *lip;
int admin_state;
NL_DBG ("link_add: netlink %U", format_nl_object, rl);
LCP_NL_DBG ("link_add: netlink %U", format_nl_object, rl);
/* For NEWLINK messages, if this interface doesn't have a LIP, it
* may be a request to create a sub-int; so we call add_vlan()
@ -815,7 +815,7 @@ lcp_nl_link_add (struct rtnl_link *rl, void *ctx)
}
admin_state = (IFF_UP & rtnl_link_get_flags (rl));
// Note: cannot use lcp_itf_set_link_state() here because it creates a loop
// Note: Cannot use lcp_itf_set_link_state() here because it creates a loop
// by sending a netlink message.
if (admin_state)
{
@ -829,7 +829,7 @@ lcp_nl_link_add (struct rtnl_link *rl, void *ctx)
lcp_nl_link_set_mtu (rl, lip);
lcp_nl_link_set_lladdr (rl, lip);
NL_INFO ("link_add: %U admin %s", format_lcp_itf_pair, lip,
LCP_NL_INFO ("link_add: %U admin %s", format_lcp_itf_pair, lip,
admin_state ? "up" : "down");
return;
@ -907,12 +907,12 @@ lcp_nl_addr_add_del (struct rtnl_addr *ra, int is_del)
lcp_itf_pair_t *lip;
ip_address_t nh;
NL_DBG ("addr_%s: netlink %U", is_del ? "del" : "add", format_nl_object, ra);
LCP_NL_DBG ("addr_%s: netlink %U", is_del ? "del" : "add", format_nl_object, ra);
if (!(lip = lcp_itf_pair_get (
lcp_itf_pair_find_by_vif (rtnl_addr_get_ifindex (ra)))))
{
NL_WARN ("addr_%s: no LCP for %U ", is_del ? "del" : "add",
LCP_NL_WARN ("addr_%s: No LIP for %U ", is_del ? "del" : "add",
format_nl_object, ra);
return;
}
@ -944,7 +944,7 @@ lcp_nl_addr_add_del (struct rtnl_addr *ra, int is_del)
lcp_nl_ip6_mroutes_add_del (lip->lip_phy_sw_if_index, !is_del);
}
NL_NOTICE ("addr_%s %U/%d iface %U", is_del ? "del: Deleted" : "add: Added",
LCP_NL_NOTICE ("addr_%s %U/%d iface %U", is_del ? "del: Deleted" : "add: Added",
format_ip_address, &nh, rtnl_addr_get_prefixlen (ra),
format_vnet_sw_if_index_name, vnet_get_main (),
lip->lip_phy_sw_if_index);
@ -971,24 +971,24 @@ lcp_nl_neigh_add (struct rtnl_neigh *rn)
int state;
struct nl_addr *rna;
NL_DBG ("neigh_add: netlink %U", format_nl_object, rn);
LCP_NL_DBG ("neigh_add: netlink %U", format_nl_object, rn);
if (!(lip = lcp_itf_pair_get (
lcp_itf_pair_find_by_vif (rtnl_neigh_get_ifindex (rn)))))
{
NL_WARN ("neigh_add: no LCP for %U ", format_nl_object, rn);
LCP_NL_WARN ("neigh_add: No LIP for %U ", format_nl_object, rn);
return;
}
if (ip46_address_is_multicast (&ip_addr_46 (&nh)))
{
NL_DBG ("neigh_add: ignore multicast %U", format_nl_object, rn);
LCP_NL_DBG ("neigh_add: ignore multicast %U", format_nl_object, rn);
return;
}
if ((rna = rtnl_neigh_get_dst (rn)) == NULL)
{
NL_DBG ("neigh_del: ignore missing neighbor %U", format_nl_object, rn);
LCP_NL_DBG ("neigh_del: ignore missing neighbor %U", format_nl_object, rn);
return;
}
lcp_nl_mk_ip_addr (rna, &nh);
@ -1012,14 +1012,14 @@ lcp_nl_neigh_add (struct rtnl_neigh *rn)
if (rv)
{
NL_ERROR ("neigh_add: Failed %U lladdr %U iface %U",
LCP_NL_ERROR ("neigh_add: Failed %U lladdr %U iface %U",
format_ip_address, &nh, format_mac_address, &mac,
format_vnet_sw_if_index_name, vnet_get_main (),
lip->lip_phy_sw_if_index);
}
else
{
NL_INFO ("neigh_add: Added %U lladdr %U iface %U", format_ip_address,
LCP_NL_INFO ("neigh_add: Added %U lladdr %U iface %U", format_ip_address,
&nh, format_mac_address, &mac, format_vnet_sw_if_index_name,
vnet_get_main (), lip->lip_phy_sw_if_index);
}
@ -1032,25 +1032,25 @@ lcp_nl_neigh_del (struct rtnl_neigh *rn)
ip_address_t nh;
int rv;
struct nl_addr *rna;
NL_DBG ("neigh_del: netlink %U", format_nl_object, rn);
LCP_NL_DBG ("neigh_del: netlink %U", format_nl_object, rn);
lcp_itf_pair_t *lip;
if (!(lip = lcp_itf_pair_get (
lcp_itf_pair_find_by_vif (rtnl_neigh_get_ifindex (rn)))))
{
NL_WARN ("neigh_del: no LCP for %U ", format_nl_object, rn);
LCP_NL_WARN ("neigh_del: No LIP for %U ", format_nl_object, rn);
return;
}
if (ip46_address_is_multicast (&ip_addr_46 (&nh)))
{
NL_DBG ("neigh_del: ignore multicast %U", format_nl_object, rn);
LCP_NL_DBG ("neigh_del: ignore multicast %U", format_nl_object, rn);
return;
}
if ((rna = rtnl_neigh_get_dst (rn)) == NULL)
{
NL_DBG ("neigh_del: ignore missing neighbor %U", format_nl_object, rn);
LCP_NL_DBG ("neigh_del: ignore missing neighbor %U", format_nl_object, rn);
return;
}
lcp_nl_mk_ip_addr (rna, &nh);
@ -1058,13 +1058,13 @@ lcp_nl_neigh_del (struct rtnl_neigh *rn)
if (rv == 0 || rv == VNET_API_ERROR_NO_SUCH_ENTRY)
{
NL_INFO ("neigh_del: Deleted %U iface %U", format_ip_address, &nh,
LCP_NL_INFO ("neigh_del: Deleted %U iface %U", format_ip_address, &nh,
format_vnet_sw_if_index_name, vnet_get_main (),
lip->lip_phy_sw_if_index);
}
else
{
NL_ERROR ("neigh_del: Failed %U iface %U", format_ip_address, &nh,
LCP_NL_ERROR ("neigh_del: Failed %U iface %U", format_ip_address, &nh,
format_vnet_sw_if_index_name, vnet_get_main (),
lip->lip_phy_sw_if_index);
}