Skip to content

Commit 558827a

Browse files
committed
Skip Mac Learning support
1 parent 39b82f3 commit 558827a

5 files changed

Lines changed: 36 additions & 24 deletions

File tree

northd/en-global-config.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ en_global_config_init(struct engine_node *node OVS_UNUSED,
5454
struct ed_type_global_config *data = xzalloc(sizeof *data);
5555
smap_init(&data->nb_options);
5656
smap_init(&data->sb_options);
57+
sset_init(&data->pf9_mac_learning_skip);
5758
northd_enable_all_features(data);
5859
return data;
5960
}
@@ -100,17 +101,23 @@ en_global_config_run(struct engine_node *node , void *data)
100101
}
101102
}
102103

103-
const char *skip_mac = smap_get(&nb->external_ids,
104-
"pf9-mac-learning-skip");
105-
config_data->pf9_mac_learning_skip_set = false;
106-
if (skip_mac) {
107-
struct eth_addr ea;
108-
if (eth_addr_from_string(skip_mac, &ea)) {
109-
snprintf(config_data->pf9_mac_learning_skip,
110-
sizeof config_data->pf9_mac_learning_skip,
111-
ETH_ADDR_FMT, ETH_ADDR_ARGS(ea));
112-
config_data->pf9_mac_learning_skip_set = true;
104+
const char *skip_macs = smap_get(&nb->external_ids,
105+
"pf9-mac-learning-skip");
106+
sset_clear(&config_data->pf9_mac_learning_skip);
107+
if (skip_macs && skip_macs[0]) {
108+
struct sset raw = SSET_INITIALIZER(&raw);
109+
sset_from_delimited_string(&raw, skip_macs, ", \t\n");
110+
const char *mac;
111+
SSET_FOR_EACH (mac, &raw) {
112+
struct eth_addr ea;
113+
if (eth_addr_from_string(mac, &ea)) {
114+
char mac_str[ETH_ADDR_STRLEN + 1];
115+
snprintf(mac_str, sizeof mac_str, ETH_ADDR_FMT,
116+
ETH_ADDR_ARGS(ea));
117+
sset_add(&config_data->pf9_mac_learning_skip, mac_str);
118+
}
113119
}
120+
sset_destroy(&raw);
114121
}
115122

116123
struct smap *options = &config_data->nb_options;
@@ -178,6 +185,7 @@ void en_global_config_cleanup(void *data OVS_UNUSED)
178185
struct ed_type_global_config *config_data = data;
179186
smap_destroy(&config_data->nb_options);
180187
smap_destroy(&config_data->sb_options);
188+
sset_destroy(&config_data->pf9_mac_learning_skip);
181189
destroy_debug_config();
182190
}
183191

northd/en-global-config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/* OVS includes. */
77
#include "lib/packets.h"
88
#include "lib/smap.h"
9+
#include "lib/sset.h"
910

1011
/* OVN includes. */
1112
#include "lib/inc-proc-eng.h"
@@ -43,9 +44,8 @@ struct ed_type_global_config {
4344
char svc_monitor_mac[ETH_ADDR_STRLEN + 1];
4445
struct eth_addr svc_monitor_mac_ea;
4546

46-
/* MAC to skip from FDB learning, sourced from NB_Global.external_ids. */
47-
bool pf9_mac_learning_skip_set;
48-
char pf9_mac_learning_skip[ETH_ADDR_STRLEN + 1];
47+
/* MACs to skip from FDB learning, sourced from NB_Global.external_ids. */
48+
struct sset pf9_mac_learning_skip;
4949

5050
struct chassis_features features;
5151

northd/en-lflow.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ lflow_get_input_data(struct engine_node *node,
9090
smap_get_bool(&global_config->nb_options,
9191
"pf9-allow-mac-forged-transmits", false);
9292
lflow_input->pf9_mac_learning_skip =
93-
global_config->pf9_mac_learning_skip_set
94-
? global_config->pf9_mac_learning_skip
95-
: NULL;
93+
sset_is_empty(&global_config->pf9_mac_learning_skip)
94+
? NULL
95+
: &global_config->pf9_mac_learning_skip;
9696
}
9797

9898
void en_lflow_run(struct engine_node *node, void *data)

northd/northd.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5758,7 +5758,7 @@ static void
57585758
build_lswitch_learn_fdb_op(
57595759
struct ovn_port *op, struct lflow_table *lflows,
57605760
struct ds *actions, struct ds *match,
5761-
const char *pf9_mac_learning_skip)
5761+
const struct sset *pf9_mac_learning_skip)
57625762
{
57635763
ovs_assert(op->nbsp);
57645764

@@ -5779,9 +5779,12 @@ build_lswitch_learn_fdb_op(
57795779
op->lflow_ref);
57805780

57815781
ds_put_cstr(match, " && "REGBIT_LKUP_FDB" == 0");
5782-
if (pf9_mac_learning_skip) {
5783-
ds_put_format(match, " && eth.src != %s",
5784-
pf9_mac_learning_skip);
5782+
if (pf9_mac_learning_skip &&
5783+
!sset_is_empty(pf9_mac_learning_skip)) {
5784+
const char *skip_mac;
5785+
SSET_FOR_EACH (skip_mac, pf9_mac_learning_skip) {
5786+
ds_put_format(match, " && eth.src != %s", skip_mac);
5787+
}
57855788
}
57865789
ds_clear(actions);
57875790
ds_put_cstr(actions, "put_fdb(inport, eth.src); next;");
@@ -15794,7 +15797,7 @@ struct lswitch_flow_build_info {
1579415797
struct ds actions;
1579515798
size_t thread_lflow_counter;
1579615799
const char *svc_monitor_mac;
15797-
const char *pf9_mac_learning_skip;
15800+
const struct sset *pf9_mac_learning_skip;
1579815801
};
1579915802

1580015803
/* Helper function to combine all lflow generation which is iterated by
@@ -15877,7 +15880,7 @@ build_lswitch_and_lrouter_iterate_by_lsp(struct ovn_port *op,
1587715880
const struct hmap *ls_ports,
1587815881
const struct hmap *lr_ports,
1587915882
const struct shash *meter_groups,
15880-
const char *pf9_mac_learning_skip,
15883+
const struct sset *pf9_mac_learning_skip,
1588115884
struct ds *match,
1588215885
struct ds *actions,
1588315886
struct lflow_table *lflows)
@@ -16164,7 +16167,7 @@ build_lswitch_and_lrouter_flows(
1616416167
const struct chassis_features *features,
1616516168
const char *svc_monitor_mac,
1616616169
bool pf9_allow_mac_forged_transmits,
16167-
const char *pf9_mac_learning_skip)
16170+
const struct sset *pf9_mac_learning_skip)
1616816171
{
1616916172

1617016173
char *svc_check_match = xasprintf("eth.dst == %s", svc_monitor_mac);

northd/northd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "lib/ovn-sb-idl.h"
2020
#include "lib/ovn-util.h"
21+
#include "lib/sset.h"
2122
#include "lib/ovs-atomic.h"
2223
#include "lib/sset.h"
2324
#include "northd/en-port-group.h"
@@ -191,7 +192,7 @@ struct lflow_input {
191192
bool ovn_internal_version_changed;
192193
const char *svc_monitor_mac;
193194
bool pf9_allow_mac_forged_transmits;
194-
const char *pf9_mac_learning_skip;
195+
const struct sset *pf9_mac_learning_skip;
195196
};
196197

197198
extern int parallelization_state;

0 commit comments

Comments
 (0)