diff options
author | Jafar Al-Gharaibeh <Jafaral@users.noreply.github.com> | 2017-09-14 18:37:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-14 18:37:29 +0200 |
commit | 461b76e4ed82f3bb3f71499cfb2025959affca9b (patch) | |
tree | 920bfb0b7dda4f9b2b6c63ab6cef89472b6fa00c /pimd | |
parent | Merge pull request #1175 from donaldsharp/pim_sg_rpt_bullshit (diff) | |
parent | pimd: Allow igmp join messages to return more detailed errors (diff) | |
download | frr-461b76e4ed82f3bb3f71499cfb2025959affca9b.tar.xz frr-461b76e4ed82f3bb3f71499cfb2025959affca9b.zip |
Merge pull request #1178 from donaldsharp/pim_obfuscation
Pim debugging and ferr start usage
Diffstat (limited to 'pimd')
-rw-r--r-- | pimd/pim_cmd.c | 39 | ||||
-rw-r--r-- | pimd/pim_iface.c | 33 | ||||
-rw-r--r-- | pimd/pim_iface.h | 5 | ||||
-rw-r--r-- | pimd/pim_rp.c | 22 | ||||
-rw-r--r-- | pimd/pimd.h | 5 |
5 files changed, 62 insertions, 42 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 4a9c53cf2..4066614f4 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -28,6 +28,7 @@ #include "hash.h" #include "nexthop.h" #include "vrf.h" +#include "ferr.h" #include "pimd.h" #include "pim_mroute.h" @@ -5839,13 +5840,8 @@ DEFUN (interface_ip_igmp_join, return CMD_WARNING_CONFIG_FAILED; } - result = pim_if_igmp_join_add(ifp, group_addr, source_addr); - if (result) { - vty_out(vty, - "%% Failure joining IGMP group %s source %s on interface %s: %d\n", - group_str, source_str, ifp->name, result); - return CMD_WARNING_CONFIG_FAILED; - } + CMD_FERR_RETURN(pim_if_igmp_join_add(ifp, group_addr, source_addr), + "Failure joining IGMP group: $ERR"); return CMD_SUCCESS; } @@ -6959,6 +6955,31 @@ DEFUN (no_debug_pim_nht, return CMD_SUCCESS; } +DEFUN (debug_pim_nht_rp, + debug_pim_nht_rp_cmd, + "debug pim nht rp", + DEBUG_STR + DEBUG_PIM_STR + "Nexthop Tracking\n" + "RP Nexthop Tracking\n") +{ + PIM_DO_DEBUG_PIM_NHT_RP; + return CMD_SUCCESS; +} + +DEFUN (no_debug_pim_nht_rp, + no_debug_pim_nht_rp_cmd, + "no debug pim nht rp", + NO_STR + DEBUG_STR + DEBUG_PIM_STR + "Nexthop Tracking\n" + "RP Nexthop Tracking\n") +{ + PIM_DONT_DEBUG_PIM_NHT_RP; + return CMD_SUCCESS; +} + DEFUN (debug_pim_events, debug_pim_events_cmd, "debug pim events", @@ -8628,6 +8649,8 @@ void pim_cmd_init(void) install_element(ENABLE_NODE, &no_debug_pim_cmd); install_element(ENABLE_NODE, &debug_pim_nht_cmd); install_element(ENABLE_NODE, &no_debug_pim_nht_cmd); + install_element(ENABLE_NODE, &debug_pim_nht_rp_cmd); + install_element(ENABLE_NODE, &no_debug_pim_nht_rp_cmd); install_element(ENABLE_NODE, &debug_pim_events_cmd); install_element(ENABLE_NODE, &no_debug_pim_events_cmd); install_element(ENABLE_NODE, &debug_pim_packets_cmd); @@ -8672,6 +8695,8 @@ void pim_cmd_init(void) install_element(CONFIG_NODE, &no_debug_pim_cmd); install_element(CONFIG_NODE, &debug_pim_nht_cmd); install_element(CONFIG_NODE, &no_debug_pim_nht_cmd); + install_element(CONFIG_NODE, &debug_pim_nht_rp_cmd); + install_element(CONFIG_NODE, &no_debug_pim_nht_rp_cmd); install_element(CONFIG_NODE, &debug_pim_events_cmd); install_element(CONFIG_NODE, &no_debug_pim_events_cmd); install_element(CONFIG_NODE, &debug_pim_packets_cmd); diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 1afcff7cb..6cf18d08e 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -27,6 +27,7 @@ #include "linklist.h" #include "plist.h" #include "hash.h" +#include "ferr.h" #include "pimd.h" #include "pim_instance.h" @@ -1270,7 +1271,7 @@ static struct igmp_join *igmp_join_new(struct interface *ifp, return ij; } -int pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, +ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr) { struct pim_interface *pim_ifp; @@ -1278,17 +1279,14 @@ int pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, pim_ifp = ifp->info; if (!pim_ifp) { - zlog_warn("%s: multicast not enabled on interface %s", - __PRETTY_FUNCTION__, ifp->name); - return -1; + return ferr_cfg_invalid("multicast not enabled on interface %s", + ifp->name); } if (!pim_ifp->igmp_join_list) { pim_ifp->igmp_join_list = list_new(); if (!pim_ifp->igmp_join_list) { - zlog_err("%s %s: failure: igmp_join_list=list_new()", - __FILE__, __PRETTY_FUNCTION__); - return -2; + return ferr_cfg_invalid("Insufficient memory"); } pim_ifp->igmp_join_list->del = (void (*)(void *))igmp_join_free; } @@ -1301,24 +1299,15 @@ int pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, sizeof(group_str)); pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str)); - zlog_warn( - "%s: can't re-join existing IGMP group %s source %s on interface %s", - __PRETTY_FUNCTION__, group_str, source_str, ifp->name); - return -3; + return ferr_cfg_invalid( + "can't re-join existing IGMP group %s source %s on interface %s", + group_str, source_str, ifp->name); } ij = igmp_join_new(ifp, group_addr, source_addr); if (!ij) { - char group_str[INET_ADDRSTRLEN]; - char source_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<grp?>", group_addr, group_str, - sizeof(group_str)); - pim_inet4_dump("<src?>", source_addr, source_str, - sizeof(source_str)); - zlog_warn( - "%s: igmp_join_new() failure for IGMP group %s source %s on interface %s", - __PRETTY_FUNCTION__, group_str, source_str, ifp->name); - return -4; + return ferr_cfg_invalid( + "Failure to create new join data structure, see log file for more information"); } if (PIM_DEBUG_IGMP_EVENTS) { @@ -1333,7 +1322,7 @@ int pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, __PRETTY_FUNCTION__, source_str, group_str, ifp->name); } - return 0; + return ferr_ok(); } diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index ed885ff0e..2f27a1401 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -26,6 +26,7 @@ #include "vty.h" #include "vrf.h" #include "zclient.h" +#include "ferr.h" #include "pim_igmp.h" #include "pim_upstream.h" @@ -182,8 +183,8 @@ int pim_if_t_override_msec(struct interface *ifp); struct in_addr pim_find_primary_addr(struct interface *ifp); -int pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, - struct in_addr source_addr); +ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, + struct in_addr source_addr); int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr); diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index e2c411a30..851a861a9 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -397,7 +397,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp, nht_p.prefixlen = IPV4_MAX_BITLEN; nht_p.u.prefix4 = rp_all->rp.rpf_addr.u.prefix4; // RP address - if (PIM_DEBUG_PIM_TRACE) { + if (PIM_DEBUG_PIM_NHT_RP) { char buf[PREFIX2STR_BUFFER]; char buf1[PREFIX2STR_BUFFER]; prefix2str(&nht_p, buf, sizeof(buf)); @@ -467,7 +467,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp, nht_p.family = AF_INET; nht_p.prefixlen = IPV4_MAX_BITLEN; nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4; - if (PIM_DEBUG_PIM_TRACE) { + if (PIM_DEBUG_PIM_NHT_RP) { char buf[PREFIX2STR_BUFFER]; char buf1[PREFIX2STR_BUFFER]; prefix2str(&nht_p, buf, sizeof(buf)); @@ -534,7 +534,7 @@ int pim_rp_del(struct pim_instance *pim, const char *rp, nht_p.family = AF_INET; nht_p.prefixlen = IPV4_MAX_BITLEN; nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4; - if (PIM_DEBUG_PIM_TRACE) { + if (PIM_DEBUG_PIM_NHT_RP) { char buf[PREFIX2STR_BUFFER]; prefix2str(&nht_p, buf, sizeof(buf)); zlog_debug("%s: Deregister RP addr %s with Zebra ", @@ -579,7 +579,7 @@ void pim_rp_setup(struct pim_instance *pim) &rp_info->rp.source_nexthop, &nht_p, &rp_info->group, 1); else { - if (PIM_DEBUG_ZEBRA) { + if (PIM_DEBUG_PIM_NHT_RP) { char buf[PREFIX2STR_BUFFER]; prefix2str(&nht_p, buf, sizeof(buf)); zlog_debug( @@ -589,7 +589,7 @@ void pim_rp_setup(struct pim_instance *pim) if (!pim_nexthop_lookup( pim, &rp_info->rp.source_nexthop, rp_info->rp.rpf_addr.u.prefix4, 1)) - if (PIM_DEBUG_PIM_TRACE) + if (PIM_DEBUG_PIM_NHT_RP) zlog_debug( "Unable to lookup nexthop for rp specified"); } @@ -624,7 +624,7 @@ void pim_rp_check_on_if_add(struct pim_interface *pim_ifp) if (pim_rp_check_interface_addrs(rp_info, pim_ifp)) { i_am_rp_changed = true; rp_info->i_am_rp = 1; - if (PIM_DEBUG_ZEBRA) { + if (PIM_DEBUG_PIM_NHT_RP) { char rp[PREFIX_STRLEN]; pim_addr_dump("<rp?>", &rp_info->rp.rpf_addr, rp, sizeof(rp)); @@ -660,7 +660,7 @@ void pim_i_am_rp_re_evaluate(struct pim_instance *pim) if (old_i_am_rp != rp_info->i_am_rp) { i_am_rp_changed = true; - if (PIM_DEBUG_ZEBRA) { + if (PIM_DEBUG_PIM_NHT_RP) { char rp[PREFIX_STRLEN]; pim_addr_dump("<rp?>", &rp_info->rp.rpf_addr, rp, sizeof(rp)); @@ -728,7 +728,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group) nht_p.family = AF_INET; nht_p.prefixlen = IPV4_MAX_BITLEN; nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4; - if (PIM_DEBUG_PIM_TRACE) { + if (PIM_DEBUG_PIM_NHT_RP) { char buf[PREFIX2STR_BUFFER]; char buf1[PREFIX2STR_BUFFER]; prefix2str(&nht_p, buf, sizeof(buf)); @@ -743,7 +743,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group) &rp_info->rp.source_nexthop, &nht_p, &rp_info->group, 1); else { - if (PIM_DEBUG_ZEBRA) { + if (PIM_DEBUG_PIM_NHT_RP) { char buf[PREFIX2STR_BUFFER]; char buf1[PREFIX2STR_BUFFER]; prefix2str(&nht_p, buf, sizeof(buf)); @@ -786,7 +786,7 @@ int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up, if ((pim_rpf_addr_is_inaddr_none(&rp_info->rp)) && (source.s_addr == INADDR_ANY)) { - if (PIM_DEBUG_PIM_TRACE) + if (PIM_DEBUG_PIM_NHT_RP) zlog_debug("%s: Received a (*,G) with no RP configured", __PRETTY_FUNCTION__); return 0; @@ -998,7 +998,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim) continue; nh_node->gate.ipv4 = nbr->source_addr; - if (PIM_DEBUG_TRACE) { + if (PIM_DEBUG_PIM_NHT_RP) { char str[PREFIX_STRLEN]; char str1[INET_ADDRSTRLEN]; pim_inet4_dump("<nht_nbr?>", nbr->source_addr, diff --git a/pimd/pimd.h b/pimd/pimd.h index c4431651e..cd00a2df4 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -111,6 +111,8 @@ #define PIM_MASK_MSDP_INTERNAL (1 << 21) #define PIM_MASK_PIM_NHT (1 << 22) #define PIM_MASK_PIM_NHT_DETAIL (1 << 23) +#define PIM_MASK_PIM_NHT_RP (1 << 24) +/* Remember 32 bits!!! */ /* PIM error codes */ #define PIM_SUCCESS 0 @@ -185,6 +187,7 @@ extern int32_t qpim_register_probe_time; #define PIM_DEBUG_MSDP_INTERNAL (qpim_debugs & PIM_MASK_MSDP_INTERNAL) #define PIM_DEBUG_PIM_NHT (qpim_debugs & PIM_MASK_PIM_NHT) #define PIM_DEBUG_PIM_NHT_DETAIL (qpim_debugs & PIM_MASK_PIM_NHT_DETAIL) +#define PIM_DEBUG_PIM_NHT_RP (qpim_debugs & PIM_MASK_PIM_NHT_RP) #define PIM_DEBUG_EVENTS (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS | PIM_MASK_MSDP_EVENTS)) #define PIM_DEBUG_PACKETS (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS | PIM_MASK_MSDP_PACKETS)) @@ -212,6 +215,7 @@ extern int32_t qpim_register_probe_time; #define PIM_DO_DEBUG_MSDP_PACKETS (qpim_debugs |= PIM_MASK_MSDP_PACKETS) #define PIM_DO_DEBUG_MSDP_INTERNAL (qpim_debugs |= PIM_MASK_MSDP_INTERNAL) #define PIM_DO_DEBUG_PIM_NHT (qpim_debugs |= PIM_MASK_PIM_NHT) +#define PIM_DO_DEBUG_PIM_NHT_RP (qpim_debugs |= PIM_MASK_PIM_NHT_RP) #define PIM_DONT_DEBUG_PIM_EVENTS (qpim_debugs &= ~PIM_MASK_PIM_EVENTS) #define PIM_DONT_DEBUG_PIM_PACKETS (qpim_debugs &= ~PIM_MASK_PIM_PACKETS) @@ -235,6 +239,7 @@ extern int32_t qpim_register_probe_time; #define PIM_DONT_DEBUG_MSDP_PACKETS (qpim_debugs &= ~PIM_MASK_MSDP_PACKETS) #define PIM_DONT_DEBUG_MSDP_INTERNAL (qpim_debugs &= ~PIM_MASK_MSDP_INTERNAL) #define PIM_DONT_DEBUG_PIM_NHT (qpim_debugs &= ~PIM_MASK_PIM_NHT) +#define PIM_DONT_DEBUG_PIM_NHT_RP (qpim_debugs &= ~PIM_MASK_PIM_NHT_RP) void pim_init(void); void pim_terminate(void); |