summaryrefslogtreecommitdiffstats
path: root/pimd/pim_hello.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-01-14 18:03:21 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2022-02-14 06:45:03 +0100
commit11928ecf19e8b750b731b526863668197f38f9d6 (patch)
treeab6083ae16dba6bcf421dcc5cfeba977c55dfd25 /pimd/pim_hello.c
parentpim6d: IPv6-adjust neigh->source_addr (diff)
downloadfrr-11928ecf19e8b750b731b526863668197f38f9d6.tar.xz
frr-11928ecf19e8b750b731b526863668197f38f9d6.zip
pim6d: IPv6-adjust Hello/TLV processing
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'pimd/pim_hello.c')
-rw-r--r--pimd/pim_hello.c168
1 files changed, 56 insertions, 112 deletions
diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c
index 45ea6a956..fe4f10aa6 100644
--- a/pimd/pim_hello.c
+++ b/pimd/pim_hello.c
@@ -33,81 +33,62 @@
#include "pim_upstream.h"
#include "pim_bsm.h"
-static void on_trace(const char *label, struct interface *ifp,
- struct in_addr src)
+static void on_trace(const char *label, struct interface *ifp, pim_addr src)
{
- if (PIM_DEBUG_PIM_TRACE) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src, src_str, sizeof(src_str));
- zlog_debug("%s: from %s on %s", label, src_str, ifp->name);
- }
+ if (PIM_DEBUG_PIM_TRACE)
+ zlog_debug("%s: from %pPAs on %s", label, &src, ifp->name);
}
static void tlv_trace_bool(const char *label, const char *tlv_name,
- const char *ifname, struct in_addr src_addr,
- int isset, int value)
+ const char *ifname, pim_addr src_addr, int isset,
+ int value)
{
- if (isset) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
+ if (isset)
zlog_debug(
- "%s: PIM hello option from %s on interface %s: %s=%d",
- label, src_str, ifname, tlv_name, value);
- }
+ "%s: PIM hello option from %pPAs on interface %s: %s=%d",
+ label, &src_addr, ifname, tlv_name, value);
}
static void tlv_trace_uint16(const char *label, const char *tlv_name,
- const char *ifname, struct in_addr src_addr,
- int isset, uint16_t value)
+ const char *ifname, pim_addr src_addr, int isset,
+ uint16_t value)
{
- if (isset) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
+ if (isset)
zlog_debug(
- "%s: PIM hello option from %s on interface %s: %s=%u",
- label, src_str, ifname, tlv_name, value);
- }
+ "%s: PIM hello option from %pPAs on interface %s: %s=%u",
+ label, &src_addr, ifname, tlv_name, value);
}
static void tlv_trace_uint32(const char *label, const char *tlv_name,
- const char *ifname, struct in_addr src_addr,
- int isset, uint32_t value)
+ const char *ifname, pim_addr src_addr, int isset,
+ uint32_t value)
{
- if (isset) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
+ if (isset)
zlog_debug(
- "%s: PIM hello option from %s on interface %s: %s=%u",
- label, src_str, ifname, tlv_name, value);
- }
+ "%s: PIM hello option from %pPAs on interface %s: %s=%u",
+ label, &src_addr, ifname, tlv_name, value);
}
static void tlv_trace_uint32_hex(const char *label, const char *tlv_name,
- const char *ifname, struct in_addr src_addr,
+ const char *ifname, pim_addr src_addr,
int isset, uint32_t value)
{
- if (isset) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
+ if (isset)
zlog_debug(
- "%s: PIM hello option from %s on interface %s: %s=%08x",
- label, src_str, ifname, tlv_name, value);
- }
+ "%s: PIM hello option from %pPAs on interface %s: %s=%08x",
+ label, &src_addr, ifname, tlv_name, value);
}
static void tlv_trace_list(const char *label, const char *tlv_name,
- const char *ifname, struct in_addr src_addr,
- int isset, struct list *addr_list)
+ const char *ifname, pim_addr src_addr, int isset,
+ struct list *addr_list)
{
- if (isset) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
+ if (isset)
zlog_debug(
- "%s: PIM hello option from %s on interface %s: %s size=%d list=%p",
- label, src_str, ifname, tlv_name,
+ "%s: PIM hello option from %pPAs on interface %s: %s size=%d list=%p",
+ label, &src_addr, ifname, tlv_name,
addr_list ? ((int)listcount(addr_list)) : -1,
(void *)addr_list);
- }
}
#define FREE_ADDR_LIST \
@@ -121,8 +102,8 @@ static void tlv_trace_list(const char *label, const char *tlv_name,
return (code); \
}
-int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
- uint8_t *tlv_buf, int tlv_buf_size)
+int pim_hello_recv(struct interface *ifp, pim_addr src_addr, uint8_t *tlv_buf,
+ int tlv_buf_size)
{
struct pim_interface *pim_ifp;
struct pim_neighbor *neigh;
@@ -158,15 +139,11 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
int remain = tlv_pastend - tlv_curr;
if (remain < PIM_TLV_MIN_SIZE) {
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: short PIM hello TLV size=%d < min=%d from %s on interface %s",
+ "%s: short PIM hello TLV size=%d < min=%d from %pPAs on interface %s",
__func__, remain, PIM_TLV_MIN_SIZE,
- src_str, ifp->name);
- }
+ &src_addr, ifp->name);
FREE_ADDR_LIST_THEN_RETURN(-1);
}
@@ -176,28 +153,20 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
tlv_curr += PIM_TLV_LENGTH_SIZE;
if ((tlv_curr + option_len) > tlv_pastend) {
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: long PIM hello TLV type=%d length=%d > left=%td from %s on interface %s",
+ "%s: long PIM hello TLV type=%d length=%d > left=%td from %pPAs on interface %s",
__func__, option_type, option_len,
- tlv_pastend - tlv_curr, src_str,
+ tlv_pastend - tlv_curr, &src_addr,
ifp->name);
- }
FREE_ADDR_LIST_THEN_RETURN(-2);
}
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: parse left_size=%d: PIM hello TLV type=%d length=%d from %s on %s",
+ "%s: parse left_size=%d: PIM hello TLV type=%d length=%d from %pPAs on %s",
__func__, remain, option_type, option_len,
- src_str, ifp->name);
- }
+ &src_addr, ifp->name);
switch (option_type) {
case PIM_MSG_OPTION_TYPE_HOLDTIME:
@@ -242,26 +211,18 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
}
break;
case PIM_MSG_OPTION_TYPE_DM_STATE_REFRESH:
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: ignoring PIM hello dense-mode state refresh TLV option type=%d length=%d from %s on interface %s",
+ "%s: ignoring PIM hello dense-mode state refresh TLV option type=%d length=%d from %pPAs on interface %s",
__func__, option_type, option_len,
- src_str, ifp->name);
- }
+ &src_addr, ifp->name);
break;
default:
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: ignoring unknown PIM hello TLV type=%d length=%d from %s on interface %s",
+ "%s: ignoring unknown PIM hello TLV type=%d length=%d from %pPAs on interface %s",
__func__, option_type, option_len,
- src_str, ifp->name);
- }
+ &src_addr, ifp->name);
}
tlv_curr += option_len;
@@ -310,14 +271,10 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
}
if (!PIM_OPTION_IS_SET(hello_options, PIM_OPTION_MASK_HOLDTIME)) {
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: PIM hello missing holdtime from %s on interface %s",
- __func__, src_str, ifp->name);
- }
+ "%s: PIM hello missing holdtime from %pPAs on interface %s",
+ __func__, &src_addr, ifp->name);
}
/*
@@ -335,14 +292,10 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
hello_option_dr_priority, hello_option_generation_id,
hello_option_addr_list, PIM_NEIGHBOR_SEND_DELAY);
if (!neigh) {
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_warn(
- "%s: failure creating PIM neighbor %s on interface %s",
- __func__, src_str, ifp->name);
- }
+ "%s: failure creating PIM neighbor %pPAs on interface %s",
+ __func__, &src_addr, ifp->name);
FREE_ADDR_LIST_THEN_RETURN(-8);
}
/* Forward BSM if required */
@@ -368,16 +321,12 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
|| (hello_option_generation_id != neigh->generation_id)) {
/* GenID mismatch, then replace neighbor */
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: GenId mismatch new=%08x old=%08x: replacing neighbor %s on %s",
+ "%s: GenId mismatch new=%08x old=%08x: replacing neighbor %pPAs on %s",
__func__, hello_option_generation_id,
- neigh->generation_id, src_str,
+ neigh->generation_id, &src_addr,
ifp->name);
- }
pim_upstream_rpf_genid_changed(pim_ifp->pim,
neigh->source_addr);
@@ -392,15 +341,10 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
hello_option_addr_list,
PIM_NEIGHBOR_SEND_NOW);
if (!neigh) {
- if (PIM_DEBUG_PIM_HELLO) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr,
- src_str,
- sizeof(src_str));
+ if (PIM_DEBUG_PIM_HELLO)
zlog_debug(
- "%s: failure re-creating PIM neighbor %s on interface %s",
- __func__, src_str, ifp->name);
- }
+ "%s: failure re-creating PIM neighbor %pPAs on interface %s",
+ __func__, &src_addr, ifp->name);
FREE_ADDR_LIST_THEN_RETURN(-9);
}
/* Forward BSM if required */