#include "filter.h"
#include "stream.h"
#include "jhash.h"
+#include "frrstr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_community.h"
return lcom;
}
+/* Helper to check if every octet do not exceed UINT_MAX */
+static int lcommunity_list_valid(const char *community)
+{
+ int octets = 0;
+ char **splits;
+ int num;
+
+ frrstr_split(community, ":", &splits, &num);
+
+ for (int i = 0; i < num; i++) {
+ if (strtoul(splits[i], NULL, 10) > UINT_MAX)
+ return 0;
+
+ if (strlen(splits[i]) == 0)
+ return 0;
+
+ octets++;
+ XFREE(MTYPE_TMP, splits[i]);
+ }
+ XFREE(MTYPE_TMP, splits);
+
+ if (octets < 3)
+ return 0;
+
+ return 1;
+}
+
/* Set lcommunity-list. */
int lcommunity_list_set(struct community_list_handler *ch, const char *name,
const char *str, int direct, int style)
}
if (str) {
+ if (!lcommunity_list_valid(str))
+ return COMMUNITY_LIST_ERR_MALFORMED_VAL;
+
if (style == LARGE_COMMUNITY_LIST_STANDARD)
lcom = lcommunity_str2com(str);
else
/* Do not put duplicated community entry. */
if (community_list_dup_check(list, entry))
community_entry_free(entry);
- else
+ else {
community_list_entry_add(list, entry);
+ route_map_notify_dependencies(name, RMAP_EVENT_LLIST_ADDED);
+ }
return 0;
}
/* Delete all of entry belongs to this community-list. */
if (!str) {
community_list_delete(cm, list);
+ route_map_notify_dependencies(name, RMAP_EVENT_LLIST_DELETED);
return 0;
}
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;
community_list_entry_delete(cm, list, entry);
+ route_map_notify_dependencies(name, RMAP_EVENT_LLIST_DELETED);
return 0;
}