From 48f8c3d212644a33dd0abaaa1a0c71d4decaafdf Mon Sep 17 00:00:00 2001 From: Xavier Simonart Date: Mon, 24 Jun 2019 17:01:54 +0200 Subject: Add support for igmp and multicast Multicast can be enabled through configuration or through command line - Through configuration Add multicast=mcast_address (e.g. multicast=01:00:5e:01:02:03) in the port section - Through command line run enable multicast port_id mcast_address (e.g. enable multicast 1 01:00:5e:01:02:03) IGMP join message is sent unsollicited through command line: join igmp core_id task_id ip (e.g. join igmp 1 0 224.1.1.3) To enable swap answering IGMP Query (w/ IGMP Join) - Through configuration Add igmp ipv4=ip_address within the core/task section - Through command line join igmp core_id task_id ip (e.g. join igmp 1 0 224.1.1.3) (this will 1st initiate an unsollicated join, then answer any subsequent query) UDP/TCP packets received on a multicast address (224.0.0.0 => 239.255.255.255) are discarded To stop sending responses to IGMP query: leave igmp core_id task_id Change-Id: I3808ccabf3b38b5a1e10e1b044db63aa05bcd7b5 Signed-off-by: Xavier Simonart --- VNFs/DPPD-PROX/cmd_parser.c | 84 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) (limited to 'VNFs/DPPD-PROX/cmd_parser.c') diff --git a/VNFs/DPPD-PROX/cmd_parser.c b/VNFs/DPPD-PROX/cmd_parser.c index 79c939b9..d4bfed01 100644 --- a/VNFs/DPPD-PROX/cmd_parser.c +++ b/VNFs/DPPD-PROX/cmd_parser.c @@ -53,6 +53,7 @@ #include "handle_impair.h" #include "rx_pkt.h" #include "prox_compat.h" +#include "igmp.h" static int core_task_is_valid(int lcore_id, int task_id) { @@ -1254,6 +1255,31 @@ static int parse_cmd_tot_imissed_tot(const char *str, struct input *input) return 0; } +static int parse_cmd_enable_multicast(const char *str, struct input *input) +{ + uint8_t port_id; + struct ether_addr mac; + + if (sscanf(str, "%hhu %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &port_id, mac.addr_bytes, mac.addr_bytes + 1, mac.addr_bytes + 2, mac.addr_bytes + 3, mac.addr_bytes + 4, mac.addr_bytes + 5 ) != 7) { + return -1; + } + cmd_multicast(port_id, 1, &mac); + return 0; +} + +static int parse_cmd_disable_multicast(const char *str, struct input *input) +{ + uint8_t port_id; + struct ether_addr mac; + + if (sscanf(str, "%hhu %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &port_id, mac.addr_bytes, mac.addr_bytes + 1, mac.addr_bytes + 2, mac.addr_bytes + 3, mac.addr_bytes + 4, mac.addr_bytes + 5 ) != 7) { + return -1; + } + + cmd_multicast(port_id, 0, &mac); + return 0; +} + static int parse_cmd_reset_port(const char *str, struct input *input) { uint32_t port_id; @@ -1987,6 +2013,58 @@ static int parse_cmd_accuracy(const char *str, struct input *input) return 0; } +static int parse_cmd_leave_igmp(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + + if (parse_cores_task(str, lcores, &task_id, &nb_cores)) + return -1; + + if (cores_task_are_valid(lcores, task_id, nb_cores)) { + for (unsigned int i = 0; i < nb_cores; i++) { + lcore_id = lcores[i]; + + if (!task_is_mode(lcore_id, task_id, "swap")) { + plog_err("Core %u task %u is not running swap\n", lcore_id, task_id); + } + else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + igmp_leave_group(tbase); + } + } + } + return 0; +} + +static int parse_cmd_join_igmp(const char *str, struct input *input) +{ + unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores; + uint32_t igmp_ip; + uint8_t *igmp_bytes = (uint8_t *)&igmp_ip; + + if (parse_cores_task(str, lcores, &task_id, &nb_cores)) + return -1; + if (!(str = strchr_skip_twice(str, ' '))) + return -1; + if (sscanf(str, "%hhu.%hhu.%hhu.%hhu", igmp_bytes, igmp_bytes + 1, igmp_bytes + 2, igmp_bytes + 3) != 4) { + return -1; + } + if (cores_task_are_valid(lcores, task_id, nb_cores)) { + for (unsigned int i = 0; i < nb_cores; i++) { + lcore_id = lcores[i]; + + if (!task_is_mode(lcore_id, task_id, "swap")) { + plog_err("Core %u task %u is not running swap\n", lcore_id, task_id); + } + else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + igmp_join_group(tbase, igmp_ip); + } + } + } + return 0; +} + static int parse_cmd_rx_tx_info(const char *str, struct input *input) { if (strcmp(str, "") != 0) { @@ -2100,7 +2178,9 @@ static struct cmd_str cmd_strings[] = { {"set cache class", " ", "Set cache class", parse_cmd_set_cache_class}, {"get cache class", "", "Get cache class", parse_cmd_get_cache_class}, {"get cache mask", "", "Get cache mask", parse_cmd_get_cache_mask}, - {"reset port", "", "Reset port", parse_cmd_reset_port}, + {"reset port", "", "Reset port", parse_cmd_reset_port}, + {"enable multicast", " ", "Enable multicast", parse_cmd_enable_multicast}, + {"disable multicast", " ", "Disable multicast", parse_cmd_disable_multicast}, {"ring info all", "", "Get information about ring, such as ring size and number of elements in the ring", parse_cmd_ring_info_all}, {"ring info", " ", "Get information about ring on core in task , such as ring size and number of elements in the ring", parse_cmd_ring_info}, {"port info", " [brief?]", "Get port related information, such as MAC address, socket, number of descriptors..., . Adding \"brief\" after command prints short version of output.", parse_cmd_port_info}, @@ -2115,6 +2195,8 @@ static struct cmd_str cmd_strings[] = { {"random delay_us", " ", "Set the delay in usec for the impair mode to ", parse_cmd_random_delay_us}, {"probability", " ", "Set the percent of forwarded packets for the impair mode", parse_cmd_set_probability}, {"version", "", "Show version", parse_cmd_version}, + {"join igmp", " ", "Send igmp membership report for group ", parse_cmd_join_igmp}, + {"leave igmp", " ", "Send igmp leave group", parse_cmd_leave_igmp}, {0,0,0,0}, }; -- cgit 1.2.3-korg