Ensure the plugin works well with namespaces

I've made a few cosmetic adjustments:
- introduce debug, info, notice, warn and err loggers
- remove redundant logging, and set correct (conservative) log levels
- turn the sync-state error into a warning

And a little debt paydown:
- refactor sync-state into its own function, to be called instead of
  all the spot fixes elsewhere. It's going to be the case that
  sync-state is "the reconsiliation function".
- Fix a bug in lip->lip_namespace copy: vec_dup() there doesn't seem
  to work for me, use strdup() instead and make a mental note to
  reviist.

The plugin now works with 'lcpng default netns dataplane' in its
startup.conf; and with 'lcp default netns dataplane' as its first
command. A few of these fixes should go upstream, too, which I'll
do next.
This commit is contained in:
Pim van Pelt
2021-08-14 09:40:43 +02:00
parent aab11196cf
commit 10f10d534c
3 changed files with 69 additions and 54 deletions

View File

@ -26,11 +26,17 @@
extern vlib_log_class_t lcp_itf_pair_logger;
#define LCP_ITF_PAIR_DBG(...) \
vlib_log_notice (lcp_itf_pair_logger, __VA_ARGS__);
vlib_log_debug (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_INFO(...) \
vlib_log_info (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_NOTICE(...) \
vlib_log_notice (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_WARN(...) \
vlib_log_warn (lcp_itf_pair_logger, __VA_ARGS__);
#define LCP_ITF_PAIR_ERR(...) \
vlib_log_err (lcp_itf_pair_logger, __VA_ARGS__);
@ -187,6 +193,14 @@ void lcp_itf_ip6_add_del_interface_addr (ip6_main_t *im, uword opaque,
u32 address_length,
u32 if_address_index, u32 is_del);
/* Sync all state from VPP to Linux device
*
* Note: in some circumstances, this syncer will (have to) make changes to
* the VPP interface, for example if its MTU is greater than its parent.
* See the function for rationale.
*/
void lcp_itf_pair_sync_state (lcp_itf_pair_t *lip);
/*
* fd.io coding-style-patch-verification: ON
*