diff --git a/lcpng_if_sync.c b/lcpng_if_sync.c index 598269d..9b33f3b 100644 --- a/lcpng_if_sync.c +++ b/lcpng_if_sync.c @@ -59,8 +59,8 @@ lcp_itf_pair_sync_state (lcp_itf_pair_t *lip) } 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]); + format_lcp_itf_pair, lip, sw->flags, sup_sw->flags, + sw->mtu[VNET_MTU_L3], sup_sw->mtu[VNET_MTU_L3]); /* Linux will not allow children to be admin-up if their parent is * admin-down. If child is up but parent is not, force it down. @@ -69,11 +69,10 @@ lcp_itf_pair_sync_state (lcp_itf_pair_t *lip) if (state && !(sup_sw->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)) { - 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, - sw->mtu[VNET_MTU_L3], sup_sw->mtu[VNET_MTU_L3]); + 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, + sw->mtu[VNET_MTU_L3], sup_sw->mtu[VNET_MTU_L3]); state = 0; } lcp_itf_set_link_state (lip, state); @@ -90,9 +89,9 @@ lcp_itf_pair_sync_state (lcp_itf_pair_t *lip) if (sup_sw->mtu[VNET_MTU_L3] < sw->mtu[VNET_MTU_L3]) { 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]); + "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]); mtu = sup_sw->mtu[VNET_MTU_L3]; } @@ -164,7 +163,7 @@ lcp_itf_pair_sync_state_hw (vnet_hw_interface_t *hi) if (!hi) return; LCP_IF_DBG ("sync_state_hw: hi %U", format_vnet_sw_if_index_name, - vnet_get_main (), hi->hw_if_index); + vnet_get_main (), hi->hw_if_index); vnet_hw_interface_walk_sw (vnet_get_main (), hi->hw_if_index, lcp_itf_pair_walk_sync_state_hw_cb, NULL); @@ -180,14 +179,14 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) if (!lcp_sync ()) return 0; - LCP_IF_DBG ("admin_state_change: sw %U %u", - format_vnet_sw_if_index_name, vnm, sw_if_index, - flags); + 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_IF_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)) { @@ -208,8 +207,8 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) if (!hi) return NULL; 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); + format_vnet_sw_if_index_name, vnm, si->sw_if_index, + format_vnet_sw_if_index_name, vnm, hi->sw_if_index); lcp_itf_pair_sync_state_hw (hi); @@ -227,7 +226,7 @@ lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags) return NULL; LCP_IF_DBG ("mtu_change: sw %U %u", format_vnet_sw_if_index_name, vnm, - sw_if_index, flags); + sw_if_index, flags); if (vnet_sw_interface_is_sub (vnm, sw_if_index)) { @@ -251,8 +250,8 @@ lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags) if (!hi) return NULL; 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); + format_vnet_sw_if_index_name, vnm, si->sw_if_index, + format_vnet_sw_if_index_name, vnm, hi->sw_if_index); lcp_itf_pair_sync_state_hw (hi); @@ -412,8 +411,8 @@ lcp_itf_ip4_add_del_interface_addr (ip4_main_t *im, uword opaque, return; 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); + format_vnet_sw_if_index_name, vnet_get_main (), sw_if_index, + format_ip4_address, address, address_length); lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index)); if (!lip) @@ -428,8 +427,8 @@ lcp_itf_ip4_add_del_interface_addr (ip4_main_t *im, uword opaque, } 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); + format_lcp_itf_pair, lip, format_ip4_address, address, + address_length); if (is_del) vnet_netlink_del_ip4_addr (lip->lip_vif_index, address, address_length); @@ -461,8 +460,8 @@ lcp_itf_ip6_add_del_interface_addr (ip6_main_t *im, uword opaque, return; 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); + format_vnet_sw_if_index_name, vnet_get_main (), sw_if_index, + format_ip6_address, address, address_length); lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index)); if (!lip) @@ -476,8 +475,8 @@ lcp_itf_ip6_add_del_interface_addr (ip6_main_t *im, uword opaque, clib_setns (vif_ns_fd); } 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); + format_lcp_itf_pair, lip, format_ip6_address, address, + address_length); if (is_del) vnet_netlink_del_ip6_addr (lip->lip_vif_index, address, address_length); else @@ -510,9 +509,9 @@ lcp_itf_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_create) return NULL; 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); + 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); if (is_create) { diff --git a/lcpng_interface.c b/lcpng_interface.c index e3e4c33..7a1255b 100644 --- a/lcpng_interface.c +++ b/lcpng_interface.c @@ -231,13 +231,13 @@ 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_IF_ERROR ("pair_add: Cannot add LIP - invalid host"); - return VNET_API_ERROR_INVALID_SW_IF_INDEX; + 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_IF_ERROR ("pair_add: Cannot add LIP - invalid phy"); - return VNET_API_ERROR_INVALID_SW_IF_INDEX; + LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid phy"); + return VNET_API_ERROR_INVALID_SW_IF_INDEX; } LCP_IF_NOTICE ( @@ -345,7 +345,7 @@ 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_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); } @@ -358,7 +358,7 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name) if ((err = rtnl_link_add (sk, link, NLM_F_CREATE)) < 0) { 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); } @@ -674,8 +674,8 @@ lcp_itf_set_interface_addr (const lcp_itf_pair_t *lip) lm4, ia, lip->lip_phy_sw_if_index, 1 /* honor unnumbered */, ({ ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia); LCP_IF_NOTICE ("set_interface_addr: %U add ip4 %U/%d", - format_lcp_itf_pair, lip, format_ip4_address, r4, - ia->address_length); + 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); })); @@ -684,8 +684,8 @@ lcp_itf_set_interface_addr (const lcp_itf_pair_t *lip) lm6, ia, lip->lip_phy_sw_if_index, 1 /* honor unnumbered */, ({ ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia); LCP_IF_NOTICE ("set_interface_addr: %U add ip6 %U/%d", - format_lcp_itf_pair, lip, format_ip6_address, r6, - ia->address_length); + 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); })); @@ -720,11 +720,10 @@ lcp_itf_pair_find_walk (vnet_main_t *vnm, u32 sw_if_index, void *arg) (sw->sub.eth.flags.dot1ad == match->dot1ad)) { 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, - format_vnet_sw_if_index_name, vnet_get_main (), - sw->sw_if_index); + "inner-dot1q %d: interface %U", + sw->sub.eth.outer_vlan_id, sw->sub.eth.flags.dot1ad, + sw->sub.eth.inner_vlan_id, format_vnet_sw_if_index_name, + vnet_get_main (), sw->sw_if_index); match->matched_sw_if_index = sw->sw_if_index; return WALK_STOP; } @@ -776,8 +775,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *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; } @@ -810,7 +808,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, 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 " - "sub-interface without exact-match set"); + "sub-interface without exact-match set"); return VNET_API_ERROR_INVALID_ARGUMENT; } @@ -819,24 +817,24 @@ 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_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); + 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); parent_if_index = lcp_itf_pair_find_by_phy (sw->sup_sw_if_index); if (INDEX_INVALID == parent_if_index) { LCP_IF_ERROR ("pair_create: Cannot find LIP for %U", - format_vnet_sw_if_index_name, vnet_get_main (), - sw->sup_sw_if_index); + format_vnet_sw_if_index_name, vnet_get_main (), + sw->sup_sw_if_index); return VNET_API_ERROR_INVALID_SW_IF_INDEX; } lip = lcp_itf_pair_get (parent_if_index); if (!lip) { LCP_IF_ERROR ("pair_create: Cannot create LIP for a " - "sub-interface without an LCP on the parent"); + "sub-interface without an LCP on the parent"); return VNET_API_ERROR_INVALID_ARGUMENT; } LCP_IF_DBG ("pair_create: parent %U", format_lcp_itf_pair, lip); @@ -884,25 +882,24 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, if (INDEX_INVALID == linux_parent_if_index) { 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", - format_vnet_sw_if_index_name, - vnet_get_main (), hw->sw_if_index); + "vlan %d proto %s on %U", + outer_vlan, + outer_proto == ETH_P_8021AD ? "dot1ad" : + "dot1q", + format_vnet_sw_if_index_name, vnet_get_main (), + hw->sw_if_index); return VNET_API_ERROR_INVALID_SW_IF_INDEX; } llip = lcp_itf_pair_get (linux_parent_if_index); if (!llip) { - LCP_IF_ERROR ( - "pair_create: Cannot create LIP for a " - "sub-interface without a valid Linux parent"); + LCP_IF_ERROR ("pair_create: Cannot create LIP for a " + "sub-interface without a valid Linux parent"); return VNET_API_ERROR_INVALID_ARGUMENT; } - LCP_IF_DBG ("pair_create: linux parent %U", - format_lcp_itf_pair, llip); + LCP_IF_DBG ("pair_create: linux parent %U", format_lcp_itf_pair, + llip); parent_vif_index = llip->lip_vif_index; } else @@ -915,10 +912,10 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, (const char *) host_if_name); if (err != 0) { 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); + "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) @@ -1004,8 +1001,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, tap_create_if (vm, &args); if (args.rv < 0) { - LCP_IF_ERROR ("pair_create: Cannot create TAP: retval:%d", - args.rv); + LCP_IF_ERROR ("pair_create: Cannot create TAP: retval:%d", args.rv); clib_error_free (args.error); return args.rv; } diff --git a/lcpng_interface.h b/lcpng_interface.h index 0046cb4..9a6d64d 100644 --- a/lcpng_interface.h +++ b/lcpng_interface.h @@ -23,21 +23,15 @@ extern vlib_log_class_t lcp_itf_pair_logger; -#define LCP_IF_DBG(...) \ - vlib_log_debug (lcp_itf_pair_logger, __VA_ARGS__); +#define LCP_IF_DBG(...) vlib_log_debug (lcp_itf_pair_logger, __VA_ARGS__); -#define LCP_IF_INFO(...) \ - vlib_log_info (lcp_itf_pair_logger, __VA_ARGS__); +#define LCP_IF_INFO(...) vlib_log_info (lcp_itf_pair_logger, __VA_ARGS__); -#define LCP_IF_NOTICE(...) \ - vlib_log_notice (lcp_itf_pair_logger, __VA_ARGS__); +#define LCP_IF_NOTICE(...) vlib_log_notice (lcp_itf_pair_logger, __VA_ARGS__); -#define LCP_IF_WARN(...) \ - vlib_log_warn (lcp_itf_pair_logger, __VA_ARGS__); - -#define LCP_IF_ERROR(...) \ - vlib_log_err (lcp_itf_pair_logger, __VA_ARGS__); +#define LCP_IF_WARN(...) vlib_log_warn (lcp_itf_pair_logger, __VA_ARGS__); +#define LCP_IF_ERROR(...) vlib_log_err (lcp_itf_pair_logger, __VA_ARGS__); #define foreach_lcp_itf_pair_flag _ (STALE, 0, "stale") diff --git a/lcpng_netlink.c b/lcpng_netlink.c index a408f6c..1dddab2 100644 --- a/lcpng_netlink.c +++ b/lcpng_netlink.c @@ -268,20 +268,20 @@ lcp_nl_process_msgs (void) { if ((err = nl_msg_parse (msg_info->msg, lcp_nl_dispatch, msg_info)) < 0) LCP_NL_ERROR ("process_msgs: Unable to parse object: %s", - nl_geterror (err)); + nl_geterror (err)); nlmsg_free (msg_info->msg); if (++n_msgs >= nm->batch_size) { LCP_NL_INFO ("process_msgs: batch_size %u reached, yielding", - nm->batch_size); + nm->batch_size); break; } usecs = (u64) (1e6 * (vlib_time_now (vlib_get_main ()) - start)); if (usecs >= 1e3 * nm->batch_work_ms) { LCP_NL_INFO ("process_msgs: batch_work_ms %u reached, yielding", - nm->batch_work_ms); + nm->batch_work_ms); break; } } @@ -295,13 +295,13 @@ lcp_nl_process_msgs (void) if (vec_len (nm->nl_ns.nl_msg_queue)) { 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)); + "left in queue", + n_msgs, usecs, vec_len (nm->nl_ns.nl_msg_queue)); } else { - LCP_NL_DBG ("process_msgs: Processed %u messages in %llu usecs", n_msgs, - usecs); + LCP_NL_DBG ("process_msgs: Processed %u messages in %llu usecs", + n_msgs, usecs); } } @@ -400,14 +400,15 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip) // namespaces to listen on, adding/deleting listeners dynamically, ie every // time this callback is invoked. LCP_NL_DBG ("pair_add_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) && vec_cmp(nm->nl_ns.netns_name, lip->lip_namespace)) { - 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); + 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; } @@ -415,7 +416,7 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip) if (nm->nl_ns.clib_file_index == ~0) { LCP_NL_INFO ("pair_add_cb: Adding netlink listener for netns %v", - lip->lip_namespace); + lip->lip_namespace); lcp_nl_open_socket (lip->lip_namespace); } } @@ -427,13 +428,13 @@ lcp_nl_pair_del_cb (lcp_itf_pair_t *lip) // See NOTE in lcp_nl_pair_add_cb(). 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); nm->nl_ns.clib_file_lcp_refcnt--; if (nm->nl_ns.clib_file_lcp_refcnt == 0) { LCP_NL_INFO ("pair_del_cb: Removing netlink listener for netns %v", - lip->lip_namespace); + lip->lip_namespace); lcp_nl_close_socket (); return; } @@ -458,7 +459,7 @@ lcp_nl_read_cb (clib_file_t *f) if (err < 0 && err != -NLE_AGAIN) { LCP_NL_ERROR ("read_cb: Error reading netlink socket (fd %d): %s (%d)", - f->file_descriptor, nl_geterror (err), err); + f->file_descriptor, nl_geterror (err), err); vlib_process_signal_event (vlib_get_main (), lcp_nl_process_node.index, NL_EVENT_READ_ERR, 0); } @@ -476,7 +477,7 @@ static clib_error_t * lcp_nl_error_cb (clib_file_t *f) { LCP_NL_ERROR ("error_cb: Error polling netlink socket (fd %d)", - f->file_descriptor); + f->file_descriptor); /* notify process node */ vlib_process_signal_event (vlib_get_main (), lcp_nl_process_node.index, @@ -500,7 +501,7 @@ lcp_nl_close_socket (void) if (f) { LCP_NL_DBG ("close_socket: Stopping poll of netlink fd %u", - f->file_descriptor); + f->file_descriptor); fm->file_update (f, UNIX_FILE_UPDATE_DELETE); } nm->nl_ns.clib_file_index = ~0; @@ -510,7 +511,7 @@ lcp_nl_close_socket (void) if (nm->nl_ns.sk_route) { LCP_NL_DBG ("close_socket: Closing netlink socket %d", - nl_socket_get_fd (nm->nl_ns.sk_route)); + nl_socket_get_fd (nm->nl_ns.sk_route)); nl_socket_free (nm->nl_ns.sk_route); nm->nl_ns.sk_route = NULL; } @@ -562,8 +563,9 @@ lcp_nl_open_socket (u8 *ns) nm->tx_buf_size); if (err != 0) { - 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)); + 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)); } if (dest_ns_fd != -1) @@ -587,7 +589,7 @@ lcp_nl_open_socket (u8 *ns) nm->nl_ns.clib_file_index = clib_file_add (&file_main, &rt_file); 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); + nm->nl_ns.clib_file_index, rt_file.file_descriptor, ns); } else /* clib file already created and socket was closed due to error */ @@ -598,13 +600,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); LCP_NL_DBG ("open_socket: Updated netlink file idx %u fd %u netns %s", - nm->nl_ns.clib_file_index, f->file_descriptor, ns); + 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); 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); + nl_socket_get_fd (nm->nl_ns.sk_route), nm->nl_ns.netns_name); } #include diff --git a/lcpng_netlink.h b/lcpng_netlink.h index 4e4ac20..b473523 100644 --- a/lcpng_netlink.h +++ b/lcpng_netlink.h @@ -40,11 +40,12 @@ 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 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__); +#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. */ diff --git a/lcpng_nl_sync.c b/lcpng_nl_sync.c index a26605b..376a70a 100644 --- a/lcpng_nl_sync.c +++ b/lcpng_nl_sync.c @@ -436,8 +436,8 @@ lcp_nl_route_del (struct rtnl_route *rr) entry_flags = lcp_nl_mk_route_entry_flags (rtype, table_id, rproto); 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); + rtnl_route_get_table (rr), format_fib_prefix, &pfx, + format_fib_entry_flags, entry_flags); if (pfx.fp_proto == FIB_PROTOCOL_IP6) fib_table_entry_delete (nlt->nlt_fib_index, &pfx, fib_src); else @@ -480,8 +480,8 @@ lcp_nl_route_add (struct rtnl_route *rr) ip6_address_is_link_local_unicast (&pfx.fp_addr.ip6)))) { 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); + rtnl_route_get_table (rr), format_fib_prefix, &pfx, + format_fib_entry_flags, entry_flags); return; } lcp_nl_route_path_parse_t np = { @@ -505,8 +505,8 @@ lcp_nl_route_add (struct rtnl_route *rr) lcp_nl_mk_route_mprefix (rr, &mpfx); 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); + rtnl_route_get_table (rr), format_mfib_prefix, &mpfx, + format_fib_entry_flags, entry_flags); mfib_table_entry_update (nlt->nlt_mfib_index, &mpfx, MFIB_SOURCE_PLUGIN_LOW, MFIB_RPF_ID_NONE, MFIB_ENTRY_FLAG_ACCEPT_ALL_ITF); @@ -531,8 +531,8 @@ lcp_nl_route_add (struct rtnl_route *rr) fib_src = lcp_nl_proto_fib_source (rproto); 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); + rtnl_route_get_table (rr), format_fib_prefix, &pfx, + format_fib_entry_flags, entry_flags); if (pfx.fp_proto == FIB_PROTOCOL_IP6) fib_table_entry_path_add2 (nlt->nlt_fib_index, &pfx, fib_src, @@ -544,8 +544,8 @@ lcp_nl_route_add (struct rtnl_route *rr) } else 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); + rtnl_route_get_table (rr), format_fib_prefix, &pfx, + format_fib_entry_flags, entry_flags, format_nl_object, rr); vec_free (np.paths); } @@ -579,15 +579,16 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl) */ if (!(parent_lip = lcp_itf_pair_get (lcp_itf_pair_find_by_vif (parent_idx)))) { - LCP_NL_WARN ("link_add_vlan: No LIP 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) { - LCP_NL_ERROR ("link_add_vlan: Cannot get parent of %U", format_lcp_itf_pair, - parent_lip); + LCP_NL_ERROR ("link_add_vlan: Cannot get parent of %U", + format_lcp_itf_pair, parent_lip); return NULL; } @@ -604,7 +605,7 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl) if (ntohs (proto) == ETH_P_8021AD) { LCP_NL_ERROR ("link_add_vlan: Cannot create inner dot1ad: %U", - format_nl_object, rl); + format_nl_object, rl); return NULL; } } @@ -635,7 +636,8 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl) &subid)) { 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); + format_vnet_sw_if_index_name, vnm, + parent_sw->sup_sw_if_index); lcpm->lcp_auto_subint = old_lcp_auto_subint; return NULL; } @@ -648,10 +650,10 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl) inner_vlan, outer_vlan, &phy_sw_if_index)) { 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, - parent_sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan); + "inner-dot1q %u dot1%s %u", + format_vnet_sw_if_index_name, vnm, + parent_sw->sup_sw_if_index, flags, inner_vlan, + parent_sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan); lcpm->lcp_auto_subint = old_lcp_auto_subint; return NULL; } @@ -663,35 +665,36 @@ lcp_nl_link_add_vlan (struct rtnl_link *rl) vnm, phy_lip->lip_host_sw_if_index, &subid)) { 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); + format_vnet_sw_if_index_name, vnm, + phy_lip->lip_host_sw_if_index); lcpm->lcp_auto_subint = old_lcp_auto_subint; return NULL; } - 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, - parent_lip->lip_host_sw_if_index, format_vnet_sw_if_index_name, - vnm, phy_lip->lip_host_sw_if_index); + 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, + parent_lip->lip_host_sw_if_index, format_vnet_sw_if_index_name, vnm, + phy_lip->lip_host_sw_if_index); if (vnet_create_sub_interface (phy_lip->lip_host_sw_if_index, subid, flags, inner_vlan, outer_vlan, &host_sw_if_index)) { 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, - parent_sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan); + "inner-dot1q %u dot1%s %u", + format_vnet_sw_if_index_name, vnm, + phy_lip->lip_host_sw_if_index, flags, inner_vlan, + parent_sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan); lcpm->lcp_auto_subint = old_lcp_auto_subint; return NULL; } // Always keep sub-int on the TAP up vnet_sw_interface_admin_up (vnm, host_sw_if_index); - 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); + 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); lcpm->lcp_auto_subint = old_lcp_auto_subint; u8 *if_namev = 0; @@ -726,8 +729,9 @@ lcp_nl_link_del (struct rtnl_link *rl) if (rtnl_link_is_vlan (rl)) { - LCP_NL_NOTICE ("link_del: Removing subint %U", format_vnet_sw_if_index_name, - vnet_get_main (), lip->lip_phy_sw_if_index); + 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); } @@ -830,7 +834,7 @@ lcp_nl_link_add (struct rtnl_link *rl, void *ctx) lcp_nl_link_set_lladdr (rl, lip); LCP_NL_INFO ("link_add: %U admin %s", format_lcp_itf_pair, lip, - admin_state ? "up" : "down"); + admin_state ? "up" : "down"); return; } @@ -907,13 +911,14 @@ lcp_nl_addr_add_del (struct rtnl_addr *ra, int is_del) lcp_itf_pair_t *lip; ip_address_t nh; - LCP_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))))) { LCP_NL_WARN ("addr_%s: No LIP for %U ", is_del ? "del" : "add", - format_nl_object, ra); + format_nl_object, ra); return; } @@ -944,10 +949,10 @@ 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); } - 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); + 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); } void @@ -988,7 +993,8 @@ lcp_nl_neigh_add (struct rtnl_neigh *rn) if ((rna = rtnl_neigh_get_dst (rn)) == NULL) { - LCP_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); @@ -1013,15 +1019,16 @@ lcp_nl_neigh_add (struct rtnl_neigh *rn) if (rv) { 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); + format_ip_address, &nh, format_mac_address, &mac, + format_vnet_sw_if_index_name, vnet_get_main (), + lip->lip_phy_sw_if_index); } else { - 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); + 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); } } } @@ -1050,7 +1057,8 @@ lcp_nl_neigh_del (struct rtnl_neigh *rn) if ((rna = rtnl_neigh_get_dst (rn)) == NULL) { - LCP_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); @@ -1059,13 +1067,13 @@ lcp_nl_neigh_del (struct rtnl_neigh *rn) if (rv == 0 || rv == VNET_API_ERROR_NO_SUCH_ENTRY) { 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); + format_vnet_sw_if_index_name, vnet_get_main (), + lip->lip_phy_sw_if_index); } else { 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); + format_vnet_sw_if_index_name, vnet_get_main (), + lip->lip_phy_sw_if_index); } }