Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pim 5549 Additions #304

Merged
merged 12 commits into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);

if (uj) {
char pbuf[PREFIX2STR_BUFFER];
json_row = json_object_new_object();
json_object_pim_ifp_add(json_row, ifp);

Expand All @@ -828,7 +829,10 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch

sec_list = json_object_new_array();
for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) {
json_object_array_add(sec_list, json_object_new_string(inet_ntoa(sec_addr->addr)));
json_object_array_add(sec_list,
json_object_new_string(prefix2str(&sec_addr->addr,
pbuf,
sizeof(pbuf))));
}
json_object_object_add(json_row, "secondaryAddressList", sec_list);
}
Expand Down Expand Up @@ -919,11 +923,14 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
vty_out(vty, "Use Source : %s%s", inet_ntoa(pim_ifp->update_source), VTY_NEWLINE);
}
if (pim_ifp->sec_addr_list) {
char pbuf[PREFIX2STR_BUFFER];
vty_out(vty, "Address : %s (primary)%s",
inet_ntoa(ifaddr), VTY_NEWLINE);
inet_ntoa(ifaddr), VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) {
vty_out(vty, " %s%s",
inet_ntoa(sec_addr->addr), VTY_NEWLINE);
prefix2str(&sec_addr->addr,
pbuf,
sizeof(pbuf)), VTY_NEWLINE);
}
} else {
vty_out(vty, "Address : %s%s", inet_ntoa(ifaddr), VTY_NEWLINE);
Expand Down Expand Up @@ -1608,13 +1615,9 @@ static void pim_show_neighbors_secondary(struct vty *vty)
neigh_src_str, sizeof(neigh_src_str));

for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
char neigh_sec_str[INET_ADDRSTRLEN];
char neigh_sec_str[PREFIX2STR_BUFFER];

if (p->family != AF_INET)
continue;

pim_inet4_dump("<src?>", p->u.prefix4,
neigh_sec_str, sizeof(neigh_sec_str));
prefix2str(p, neigh_sec_str, sizeof(neigh_sec_str));

vty_out(vty, "%-9s %-15s %-15s %-15s%s",
ifp->name,
Expand Down Expand Up @@ -3510,6 +3513,31 @@ DEFUN (no_ip_pim_packets,
return CMD_SUCCESS;
}

DEFUN (ip_pim_v6_secondary,
ip_pim_v6_secondary_cmd,
"ip pim send-v6-secondary",
IP_STR
"pim multicast routing\n"
"Send v6 secondary addresses\n")
{
pimg->send_v6_secondary = 1;

return CMD_SUCCESS;
}

DEFUN (no_ip_pim_v6_secondary,
no_ip_pim_v6_secondary_cmd,
"no ip pim send-v6-secondary",
NO_STR
IP_STR
"pim multicast routing\n"
"Send v6 secondary addresses\n")
{
pimg->send_v6_secondary = 0;

return CMD_SUCCESS;
}

DEFUN (ip_pim_rp,
ip_pim_rp_cmd,
"ip pim rp A.B.C.D [A.B.C.D/M]",
Expand Down Expand Up @@ -6187,6 +6215,8 @@ void pim_cmd_init()
install_element (CONFIG_NODE, &no_ip_pim_keep_alive_cmd);
install_element (CONFIG_NODE, &ip_pim_packets_cmd);
install_element (CONFIG_NODE, &no_ip_pim_packets_cmd);
install_element (CONFIG_NODE, &ip_pim_v6_secondary_cmd);
install_element (CONFIG_NODE, &no_ip_pim_v6_secondary_cmd);
install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
install_element (CONFIG_NODE, &ip_msdp_peer_cmd);
Expand Down
36 changes: 25 additions & 11 deletions pimd/pim_hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,14 @@ int pim_hello_recv(struct interface *ifp,
return 0;
}

int pim_hello_build_tlv(const char *ifname,
int pim_hello_build_tlv(struct interface *ifp,
uint8_t *tlv_buf, int tlv_buf_size,
uint16_t holdtime,
uint32_t dr_priority,
uint32_t generation_id,
uint16_t propagation_delay,
uint16_t override_interval,
int can_disable_join_suppression,
struct list *ifconnected)
int can_disable_join_suppression)
{
uint8_t *curr = tlv_buf;
uint8_t *pastend = tlv_buf + tlv_buf_size;
Expand All @@ -454,7 +453,7 @@ int pim_hello_build_tlv(const char *ifname,
if (!curr) {
if (PIM_DEBUG_PIM_HELLO) {
zlog_debug("%s: could not set PIM hello Holdtime option for interface %s",
__PRETTY_FUNCTION__, ifname);
__PRETTY_FUNCTION__, ifp->name);
}
return -1;
}
Expand All @@ -468,7 +467,7 @@ int pim_hello_build_tlv(const char *ifname,
if (!tmp) {
if (PIM_DEBUG_PIM_HELLO) {
zlog_debug("%s: could not set PIM LAN Prune Delay option for interface %s",
__PRETTY_FUNCTION__, ifname);
__PRETTY_FUNCTION__, ifp->name);
}
return -1;
}
Expand All @@ -485,7 +484,7 @@ int pim_hello_build_tlv(const char *ifname,
if (!curr) {
if (PIM_DEBUG_PIM_HELLO) {
zlog_debug("%s: could not set PIM hello DR Priority option for interface %s",
__PRETTY_FUNCTION__, ifname);
__PRETTY_FUNCTION__, ifp->name);
}
return -2;
}
Expand All @@ -498,23 +497,38 @@ int pim_hello_build_tlv(const char *ifname,
if (!curr) {
if (PIM_DEBUG_PIM_HELLO) {
zlog_debug("%s: could not set PIM hello Generation ID option for interface %s",
__PRETTY_FUNCTION__, ifname);
__PRETTY_FUNCTION__, ifp->name);
}
return -3;
}

/* Secondary Address List */
if (ifconnected) {
if (ifp->connected->count) {
curr = pim_tlv_append_addrlist_ucast(curr,
pastend,
ifconnected);
ifp->connected,
AF_INET);
if (!curr) {
if (PIM_DEBUG_PIM_HELLO) {
zlog_debug("%s: could not set PIM hello Secondary Address List option for interface %s",
__PRETTY_FUNCTION__, ifname);
zlog_debug("%s: could not set PIM hello v4 Secondary Address List option for interface %s",
__PRETTY_FUNCTION__, ifp->name);
}
return -4;
}
if (pimg->send_v6_secondary)
{
curr = pim_tlv_append_addrlist_ucast(curr,
pastend,
ifp->connected,
AF_INET6);
if (!curr) {
if (PIM_DEBUG_PIM_HELLO) {
zlog_debug("%s: could not sent PIM hello v6 secondary Address List option for interface %s",
__PRETTY_FUNCTION__, ifp->name);
}
return -4;
}
}
}

return curr - tlv_buf;
Expand Down
5 changes: 2 additions & 3 deletions pimd/pim_hello.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ int pim_hello_recv(struct interface *ifp,
struct in_addr src_addr,
uint8_t *tlv_buf, int tlv_buf_size);

int pim_hello_build_tlv(const char *ifname,
int pim_hello_build_tlv(struct interface *ifp,
uint8_t *tlv_buf, int tlv_buf_size,
uint16_t holdtime,
uint32_t dr_priority,
uint32_t generation_id,
uint16_t propagation_delay,
uint16_t override_interval,
int can_disable_join_suppression,
struct list *ifconnected);
int can_disable_join_suppression);

void pim_hello_require(struct interface *ifp);

Expand Down
67 changes: 44 additions & 23 deletions pimd/pim_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,29 @@ static int pim_sec_addr_comp(const void *p1, const void *p2)
const struct pim_secondary_addr *sec1 = p1;
const struct pim_secondary_addr *sec2 = p2;

if (ntohl(sec1->addr.s_addr) < ntohl(sec2->addr.s_addr))
if (sec1->addr.family == AF_INET &&
sec2->addr.family == AF_INET6)
return -1;

if (ntohl(sec1->addr.s_addr) > ntohl(sec2->addr.s_addr))
if (sec1->addr.family == AF_INET6 &&
sec2->addr.family == AF_INET)
return 1;

if (sec1->addr.family == AF_INET)
{
if (ntohl(sec1->addr.u.prefix4.s_addr) < ntohl(sec2->addr.u.prefix4.s_addr))
return -1;

if (ntohl(sec1->addr.u.prefix4.s_addr) > ntohl(sec2->addr.u.prefix4.s_addr))
return 1;
}
else
{
return memcmp (&sec1->addr.u.prefix6,
&sec2->addr.u.prefix6,
sizeof (struct in6_addr));
}

return 0;
}

Expand All @@ -339,7 +356,7 @@ static void pim_sec_addr_free(struct pim_secondary_addr *sec_addr)
}

static struct pim_secondary_addr *
pim_sec_addr_find(struct pim_interface *pim_ifp, struct in_addr addr)
pim_sec_addr_find(struct pim_interface *pim_ifp, struct prefix *addr)
{
struct pim_secondary_addr *sec_addr;
struct listnode *node;
Expand All @@ -349,7 +366,7 @@ pim_sec_addr_find(struct pim_interface *pim_ifp, struct in_addr addr)
}

for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, node, sec_addr)) {
if (sec_addr->addr.s_addr == addr.s_addr) {
if (prefix_cmp(&sec_addr->addr, addr)) {
return sec_addr;
}
}
Expand All @@ -364,7 +381,7 @@ static void pim_sec_addr_del(struct pim_interface *pim_ifp,
pim_sec_addr_free(sec_addr);
}

static int pim_sec_addr_add(struct pim_interface *pim_ifp, struct in_addr addr)
static int pim_sec_addr_add(struct pim_interface *pim_ifp, struct prefix *addr)
{
int changed = 0;
struct pim_secondary_addr *sec_addr;
Expand All @@ -391,7 +408,7 @@ static int pim_sec_addr_add(struct pim_interface *pim_ifp, struct in_addr addr)
}

changed = 1;
sec_addr->addr = addr;
sec_addr->addr = *addr;
listnode_add_sort(pim_ifp->sec_addr_list, sec_addr);

return changed;
Expand Down Expand Up @@ -433,10 +450,6 @@ static int pim_sec_addr_update(struct interface *ifp)
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
struct prefix *p = ifc->address;

if (p->family != AF_INET) {
continue;
}

if (PIM_INADDR_IS_ANY(p->u.prefix4)) {
continue;
}
Expand All @@ -446,7 +459,7 @@ static int pim_sec_addr_update(struct interface *ifp)
continue;
}

if (pim_sec_addr_add(pim_ifp, p->u.prefix4)) {
if (pim_sec_addr_add(pim_ifp, p)) {
changed = 1;
}
}
Expand Down Expand Up @@ -571,12 +584,15 @@ void pim_if_addr_add(struct connected *ifc)

detect_address_change(ifp, 0, __PRETTY_FUNCTION__);

if (ifc->address->family != AF_INET)
return;

if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
struct igmp_sock *igmp;

/* lookup IGMP socket */
igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->igmp_socket_list,
ifaddr);
ifaddr);
if (!igmp) {
/* if addr new, add IGMP socket */
pim_igmp_sock_add(pim_ifp->igmp_socket_list, ifaddr, ifp);
Expand Down Expand Up @@ -675,14 +691,17 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any)
ifp = ifc->ifp;
zassert(ifp);

if (ifc->address->family != AF_INET)
return;

if (PIM_DEBUG_ZEBRA) {
char buf[BUFSIZ];
prefix2str(ifc->address, buf, BUFSIZ);
zlog_debug("%s: %s ifindex=%d disconnected IP address %s %s",
__PRETTY_FUNCTION__,
ifp->name, ifp->ifindex, buf,
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY) ?
"secondary" : "primary");
__PRETTY_FUNCTION__,
ifp->name, ifp->ifindex, buf,
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY) ?
"secondary" : "primary");
}

detect_address_change(ifp, force_prim_as_any, __PRETTY_FUNCTION__);
Expand All @@ -709,12 +728,9 @@ void pim_if_addr_add_all(struct interface *ifp)
struct prefix *p = ifc->address;

if (p->family != AF_INET)
{
v6_addrs++;
continue;
}

v4_addrs++;
v6_addrs++;
else
v4_addrs++;
pim_if_addr_add(ifc);
}

Expand Down Expand Up @@ -1105,6 +1121,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
struct listnode *neighnode;
struct pim_neighbor *neigh;
struct pim_interface *pim_ifp;
struct prefix p;

zassert(ifp);

Expand All @@ -1116,14 +1133,18 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
return 0;
}

p.family = AF_INET;
p.u.prefix4 = addr;
p.prefixlen = IPV4_MAX_PREFIXLEN;

for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {

/* primary address ? */
if (neigh->source_addr.s_addr == addr.s_addr)
return neigh;

/* secondary address ? */
if (pim_neighbor_find_secondary(neigh, addr))
if (pim_neighbor_find_secondary(neigh, &p))
return neigh;
}

Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum pim_secondary_addr_flags {
};

struct pim_secondary_addr {
struct in_addr addr;
struct prefix addr;
enum pim_secondary_addr_flags flags;
};

Expand Down
6 changes: 5 additions & 1 deletion pimd/pim_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
From:
http://www.iana.org/assignments/address-family-numbers
*/
#define PIM_MSG_ADDRESS_FAMILY_IPV4 (1)
enum pim_msg_address_family {
PIM_MSG_ADDRESS_FAMILY_RESERVED,
PIM_MSG_ADDRESS_FAMILY_IPV4,
PIM_MSG_ADDRESS_FAMILY_IPV6,
};

/*
* Network Order pim_msg_hdr
Expand Down
Loading