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 ssm #291

Merged
merged 4 commits into from
Mar 31, 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
4 changes: 2 additions & 2 deletions pimd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ libpim_a_SOURCES = \
pim_ssmpingd.c pim_int.c pim_rp.c \
pim_static.c pim_br.c pim_register.c pim_routemap.c \
pim_msdp.c pim_msdp_socket.c pim_msdp_packet.c \
pim_jp_agg.c pim_nht.c
pim_jp_agg.c pim_nht.c pim_ssm.c

noinst_HEADERS = \
pim_memory.h \
Expand All @@ -66,7 +66,7 @@ noinst_HEADERS = \
pim_igmp_join.h pim_ssmpingd.h pim_int.h pim_rp.h \
pim_static.h pim_br.h pim_register.h \
pim_msdp.h pim_msdp_socket.h pim_msdp_packet.h pim_nht.h \
pim_jp_agg.h
pim_jp_agg.h pim_ssm.h

pimd_SOURCES = \
pim_main.c $(libpim_a_SOURCES)
Expand Down
168 changes: 160 additions & 8 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "pim_rp.h"
#include "pim_zlookup.h"
#include "pim_msdp.h"
#include "pim_ssm.h"

static struct cmd_node pim_global_node = {
PIM_NODE,
Expand Down Expand Up @@ -3598,6 +3599,153 @@ DEFUN (no_ip_pim_rp_prefix_list,
return pim_no_rp_cmd_worker (vty, argv[4]->arg, NULL, argv[6]->arg);
}

static int
pim_ssm_cmd_worker (struct vty *vty, const char *plist)
{
int result = pim_ssm_range_set (VRF_DEFAULT, plist);

if (result == PIM_SSM_ERR_NONE)
return CMD_SUCCESS;

switch (result)
{
case PIM_SSM_ERR_NO_VRF:
vty_out (vty, "%% VRF doesn't exist%s", VTY_NEWLINE);
break;
case PIM_SSM_ERR_DUP:
vty_out (vty, "%% duplicate config%s", VTY_NEWLINE);
break;
default:
vty_out (vty, "%% ssm range config failed%s", VTY_NEWLINE);
}

return CMD_WARNING;
}

DEFUN (ip_pim_ssm_prefix_list,
ip_pim_ssm_prefix_list_cmd,
"ip pim ssm prefix-list WORD",
IP_STR
"pim multicast routing\n"
"Source Specific Multicast\n"
"group range prefix-list filter\n"
"Name of a prefix-list\n")
{
return pim_ssm_cmd_worker (vty, argv[0]->arg);
}

DEFUN (no_ip_pim_ssm_prefix_list,
no_ip_pim_ssm_prefix_list_cmd,
"no ip pim ssm prefix-list",
NO_STR
IP_STR
"pim multicast routing\n"
"Source Specific Multicast\n"
"group range prefix-list filter\n")
{
return pim_ssm_cmd_worker (vty, NULL);
}

DEFUN (no_ip_pim_ssm_prefix_list_name,
no_ip_pim_ssm_prefix_list_name_cmd,
"no ip pim ssm prefix-list WORD",
NO_STR
IP_STR
"pim multicast routing\n"
"Source Specific Multicast\n"
"group range prefix-list filter\n"
"Name of a prefix-list\n")
{
struct pim_ssm *ssm = pimg->ssm_info;

if (ssm->plist_name && !strcmp(ssm->plist_name, argv[0]->arg))
return pim_ssm_cmd_worker (vty, NULL);

vty_out (vty, "%% pim ssm prefix-list %s doesn't exist%s",
argv[0]->arg, VTY_NEWLINE);

return CMD_WARNING;
}

static void
ip_pim_ssm_show_group_range(struct vty *vty, u_char uj)
{
struct pim_ssm *ssm = pimg->ssm_info;
const char *range_str = ssm->plist_name?ssm->plist_name:PIM_SSM_STANDARD_RANGE;

if (uj)
{
json_object *json;
json = json_object_new_object();
json_object_string_add(json, "ssmGroups", range_str);
vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
json_object_free(json);
}
else
vty_out(vty, "SSM group range : %s%s", range_str, VTY_NEWLINE);
}

DEFUN (show_ip_pim_ssm_range,
show_ip_pim_ssm_range_cmd,
"show ip pim group-type [json]",
SHOW_STR
IP_STR
PIM_STR
"PIM group type\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
ip_pim_ssm_show_group_range(vty, uj);

return CMD_SUCCESS;
}

static void
ip_pim_ssm_show_group_type(struct vty *vty, u_char uj, const char *group)
{
struct in_addr group_addr;
const char *type_str;
int result;

result = inet_pton(AF_INET, group, &group_addr);
if (result <= 0)
type_str = "invalid";
else
{
if (pim_is_group_224_4 (group_addr))
type_str = pim_is_grp_ssm (group_addr)?"SSM":"ASM";
else
type_str = "not-multicast";
}

if (uj)
{
json_object *json;
json = json_object_new_object();
json_object_string_add(json, "groupType", type_str);
vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
json_object_free(json);
}
else
vty_out(vty, "Group type : %s%s", type_str, VTY_NEWLINE);
}

DEFUN (show_ip_pim_group_type,
show_ip_pim_group_type_cmd,
"show ip pim group-type A.B.C.D [json]",
SHOW_STR
IP_STR
PIM_STR
"multicast group type\n"
"group address\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
ip_pim_ssm_show_group_type(vty, uj, argv[0]->arg);

return CMD_SUCCESS;
}

DEFUN_HIDDEN (ip_multicast_routing,
ip_multicast_routing_cmd,
"ip multicast-routing",
Expand Down Expand Up @@ -4292,7 +4440,7 @@ DEFUN (interface_no_ip_pim_drprio,
}

static int
pim_cmd_interface_add (struct interface *ifp, enum pim_interface_type itype)
pim_cmd_interface_add (struct interface *ifp)
{
struct pim_interface *pim_ifp = ifp->info;

Expand All @@ -4306,14 +4454,12 @@ pim_cmd_interface_add (struct interface *ifp, enum pim_interface_type itype)
PIM_IF_DO_PIM(pim_ifp->options);
}

pim_ifp->itype = itype;
pim_if_addr_add_all(ifp);
pim_if_membership_refresh(ifp);
return 1;
}


DEFUN (interface_ip_pim_ssm,
DEFUN_HIDDEN (interface_ip_pim_ssm,
interface_ip_pim_ssm_cmd,
"ip pim ssm",
IP_STR
Expand All @@ -4322,11 +4468,12 @@ DEFUN (interface_ip_pim_ssm,
{
VTY_DECLVAR_CONTEXT(interface, ifp);

if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SSM)) {
vty_out(vty, "Could not enable PIM SSM on interface%s", VTY_NEWLINE);
if (!pim_cmd_interface_add(ifp)) {
vty_out(vty, "Could not enable PIM SM on interface%s", VTY_NEWLINE);
return CMD_WARNING;
}

vty_out(vty, "WARN: Enabled PIM SM on interface; configure PIM SSM range if needed%s", VTY_NEWLINE);
return CMD_SUCCESS;
}

Expand All @@ -4338,7 +4485,7 @@ DEFUN (interface_ip_pim_sm,
IFACE_PIM_SM_STR)
{
VTY_DECLVAR_CONTEXT(interface, ifp);
if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SM)) {
if (!pim_cmd_interface_add(ifp)) {
vty_out(vty, "Could not enable PIM SM on interface%s", VTY_NEWLINE);
return CMD_WARNING;
}
Expand Down Expand Up @@ -4374,7 +4521,7 @@ pim_cmd_interface_delete (struct interface *ifp)
return 1;
}

DEFUN (interface_no_ip_pim_ssm,
DEFUN_HIDDEN (interface_no_ip_pim_ssm,
interface_no_ip_pim_ssm_cmd,
"no ip pim ssm",
NO_STR
Expand Down Expand Up @@ -6029,6 +6176,9 @@ void pim_cmd_init()
install_element (CONFIG_NODE, &no_ip_pim_rp_cmd);
install_element (CONFIG_NODE, &ip_pim_rp_prefix_list_cmd);
install_element (CONFIG_NODE, &no_ip_pim_rp_prefix_list_cmd);
install_element (CONFIG_NODE, &no_ip_pim_ssm_prefix_list_cmd);
install_element (CONFIG_NODE, &no_ip_pim_ssm_prefix_list_name_cmd);
install_element (CONFIG_NODE, &ip_pim_ssm_prefix_list_cmd);
install_element (CONFIG_NODE, &ip_pim_register_suppress_cmd);
install_element (CONFIG_NODE, &no_ip_pim_register_suppress_cmd);
install_element (CONFIG_NODE, &ip_pim_joinprune_time_cmd);
Expand Down Expand Up @@ -6186,6 +6336,8 @@ void pim_cmd_init()
install_element (VIEW_NODE, &show_ip_msdp_sa_detail_cmd);
install_element (VIEW_NODE, &show_ip_msdp_sa_sg_cmd);
install_element (VIEW_NODE, &show_ip_msdp_mesh_group_cmd);
install_element (VIEW_NODE, &show_ip_pim_ssm_range_cmd);
install_element (VIEW_NODE, &show_ip_pim_group_type_cmd);
install_element (INTERFACE_NODE, &interface_pim_use_source_cmd);
install_element (INTERFACE_NODE, &interface_no_pim_use_source_cmd);
}
6 changes: 0 additions & 6 deletions pimd/pim_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ struct pim_iface_upstream_switch {
struct list *us;
};

enum pim_interface_type {
PIM_INTERFACE_SSM,
PIM_INTERFACE_SM
};

enum pim_secondary_addr_flags {
PIM_SEC_ADDRF_NONE = 0,
PIM_SEC_ADDRF_STALE = (1 << 0)
Expand All @@ -74,7 +69,6 @@ struct pim_secondary_addr {
};

struct pim_interface {
enum pim_interface_type itype;
uint32_t options; /* bit vector */
ifindex_t mroute_vif_index;
struct in_addr primary_address; /* remember addr to detect change */
Expand Down
13 changes: 13 additions & 0 deletions pimd/pim_ifchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "pim_macro.h"
#include "pim_oil.h"
#include "pim_upstream.h"
#include "pim_ssm.h"

int
pim_ifchannel_compare (struct pim_ifchannel *ch1, struct pim_ifchannel *ch2)
Expand Down Expand Up @@ -967,6 +968,18 @@ pim_ifchannel_local_membership_add(struct interface *ifp,
if (!PIM_IF_TEST_PIM(pim_ifp->options))
return 0;

/* skip (*,G) ch creation if G is of type SSM */
if (sg->src.s_addr == INADDR_ANY)
{
if (pim_is_grp_ssm (sg->grp))
{
if (PIM_DEBUG_PIM_EVENTS)
zlog_debug("%s: local membership (S,G)=%s ignored as group is SSM",
__PRETTY_FUNCTION__, pim_str_sg_dump (sg));
return 1;
}
}

ch = pim_ifchannel_add(ifp, sg, PIM_UPSTREAM_FLAG_MASK_SRC_IGMP);
if (!ch) {
return 0;
Expand Down
5 changes: 2 additions & 3 deletions pimd/pim_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "pim_zebra.h"
#include "pim_msdp.h"
#include "pim_iface.h"
#include "pim_rp.h"

extern struct host host;

Expand Down Expand Up @@ -120,8 +119,8 @@ int main(int argc, char** argv, char** envp) {
pim_vrf_init ();
access_list_init();
prefix_list_init ();
prefix_list_add_hook (pim_rp_prefix_list_update);
prefix_list_delete_hook (pim_rp_prefix_list_update);
prefix_list_add_hook (pim_prefix_list_update);
prefix_list_delete_hook (pim_prefix_list_update);

pim_route_map_init ();
pim_init();
Expand Down
1 change: 1 addition & 0 deletions pimd/pim_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ DEFINE_MTYPE(PIMD, PIM_JP_AGG_GROUP, "PIM JP AGG Group")
DEFINE_MTYPE(PIMD, PIM_JP_AGG_SOURCE, "PIM JP AGG Source")
DEFINE_MTYPE(PIMD, PIM_PIM_INSTANCE, "PIM global state")
DEFINE_MTYPE(PIMD, PIM_NEXTHOP_CACHE, "PIM nexthop cache state")
DEFINE_MTYPE(PIMD, PIM_SSM_INFO, "PIM SSM configuration")
1 change: 1 addition & 0 deletions pimd/pim_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ DECLARE_MTYPE(PIM_JP_AGG_GROUP)
DECLARE_MTYPE(PIM_JP_AGG_SOURCE)
DECLARE_MTYPE(PIM_PIM_INSTANCE)
DECLARE_MTYPE(PIM_NEXTHOP_CACHE)
DECLARE_MTYPE(PIM_SSM_INFO)

#endif /* _QUAGGA_PIM_MEMORY_H */
Loading