Skip to content

Commit ea44955

Browse files
maxime-leroychristophefontaine
authored andcommitted
treewide: prefix all event constants with GR_EVENT
EVENT macro definitions are part of the exposed API. This commit adds a `GR_` prefix to all occurrences of `*_EVENT_` to namespace them properly and avoid potential conflicts. Signed-off-by: Maxime Leroy <[email protected]>
1 parent da2a0de commit ea44955

22 files changed

+104
-104
lines changed

main/api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ static evutil_socket_t *all_events_subs;
3939
// struct module_subscribers
4040
// sockets
4141
// +--------+
42-
// IFACE_EVENT_UNKNOWN | 0x0000 |
42+
// GR_EVENT_IFACE_UNKNOWN | 0x0000 |
4343
// |--------|
44-
// IFACE_EVENT_POST_ADD | 0x0001 |
44+
// GR_EVENT_IFACE_POST_ADD | 0x0001 |
4545
// |--------|
4646
// | ...... |
4747
// |--------|
48-
// NEXTHOP_EVENT_UPDATE -> | 0x0102 | -> gr_vec of evutil_socket_t
48+
// GR_EVENT_NEXTHOP_UPDATE -> | 0x0102 | -> gr_vec of evutil_socket_t
4949
// |--------|
5050
// | ...... |
5151
// |--------|

modules/infra/api/gr_infra.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ struct gr_infra_stat {
137137

138138
//! Interface events.
139139
typedef enum {
140-
IFACE_EVENT_UNKNOWN = EVENT_TYPE(GR_INFRA_MODULE, 0x0000),
141-
IFACE_EVENT_POST_ADD = EVENT_TYPE(GR_INFRA_MODULE, 0x0001),
142-
IFACE_EVENT_PRE_REMOVE = EVENT_TYPE(GR_INFRA_MODULE, 0x0002),
143-
IFACE_EVENT_POST_RECONFIG = EVENT_TYPE(GR_INFRA_MODULE, 0x0003),
144-
IFACE_EVENT_STATUS_UP = EVENT_TYPE(GR_INFRA_MODULE, 0x0004),
145-
IFACE_EVENT_STATUS_DOWN = EVENT_TYPE(GR_INFRA_MODULE, 0x0005),
146-
} iface_event_t;
140+
GR_EVENT_IFACE_UNKNOWN = EVENT_TYPE(GR_INFRA_MODULE, 0x0000),
141+
GR_EVENT_IFACE_POST_ADD = EVENT_TYPE(GR_INFRA_MODULE, 0x0001),
142+
GR_EVENT_IFACE_PRE_REMOVE = EVENT_TYPE(GR_INFRA_MODULE, 0x0002),
143+
GR_EVENT_IFACE_POST_RECONFIG = EVENT_TYPE(GR_INFRA_MODULE, 0x0003),
144+
GR_EVENT_IFACE_STATUS_UP = EVENT_TYPE(GR_INFRA_MODULE, 0x0004),
145+
GR_EVENT_IFACE_STATUS_DOWN = EVENT_TYPE(GR_INFRA_MODULE, 0x0005),
146+
} gr_event_iface_t;
147147

148148
// ifaces ///////////////////////////////////////////////////////////////////////
149149
#define GR_INFRA_IFACE_ADD REQUEST_TYPE(GR_INFRA_MODULE, 0x0001)

modules/infra/api/gr_nexthop.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ struct gr_nexthop {
5151

5252
//! Nexthop events.
5353
typedef enum {
54-
NEXTHOP_EVENT_NEW = EVENT_TYPE(GR_INFRA_MODULE, 0x0100),
55-
NEXTHOP_EVENT_DELETE = EVENT_TYPE(GR_INFRA_MODULE, 0x0101),
56-
NEXTHOP_EVENT_UPDATE = EVENT_TYPE(GR_INFRA_MODULE, 0x0102),
57-
} nexthop_event_t;
54+
GR_EVENT_NEXTHOP_NEW = EVENT_TYPE(GR_INFRA_MODULE, 0x0100),
55+
GR_EVENT_NEXTHOP_DELETE = EVENT_TYPE(GR_INFRA_MODULE, 0x0101),
56+
GR_EVENT_NEXTHOP_UPDATE = EVENT_TYPE(GR_INFRA_MODULE, 0x0102),
57+
} gr_event_nexthop_t;
5858

5959
#define gr_nh_flags_foreach(f, flags) \
6060
for (gr_nh_flags_t __i = 0, f = GR_BIT16(0); __i < sizeof(gr_nh_flags_t) * CHAR_BIT; \

modules/infra/api/iface.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ static struct gr_event_serializer iface_serializer = {
148148
.callback = iface_event_serialize,
149149
.ev_count = 5,
150150
.ev_types = {
151-
IFACE_EVENT_POST_ADD,
152-
IFACE_EVENT_PRE_REMOVE,
153-
IFACE_EVENT_POST_RECONFIG,
154-
IFACE_EVENT_STATUS_UP,
155-
IFACE_EVENT_STATUS_DOWN,
151+
GR_EVENT_IFACE_POST_ADD,
152+
GR_EVENT_IFACE_PRE_REMOVE,
153+
GR_EVENT_IFACE_POST_RECONFIG,
154+
GR_EVENT_IFACE_STATUS_UP,
155+
GR_EVENT_IFACE_STATUS_DOWN,
156156
},
157157
};
158158

modules/infra/api/trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static struct gr_api_handler clear_packet_log_handler = {
122122
static struct gr_event_subscription iface_add_sub = {
123123
.callback = iface_add_callback,
124124
.ev_count = 1,
125-
.ev_types = {IFACE_EVENT_POST_ADD},
125+
.ev_types = {GR_EVENT_IFACE_POST_ADD},
126126
};
127127

128128
RTE_INIT(trace_init) {

modules/infra/cli/events.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,50 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
2121

2222
while (gr_api_client_event_recv(c, &e) == 0) {
2323
switch (e->ev_type) {
24-
case IFACE_EVENT_POST_ADD:
24+
case GR_EVENT_IFACE_POST_ADD:
2525
assert(e->payload_len == sizeof(*p));
2626
p = PAYLOAD(e);
2727
printf("> iface add: %s\n", p->iface.name);
2828
break;
29-
case IFACE_EVENT_PRE_REMOVE:
29+
case GR_EVENT_IFACE_PRE_REMOVE:
3030
assert(e->payload_len == sizeof(*p));
3131
p = PAYLOAD(e);
3232
printf("> iface del: %s\n", p->iface.name);
3333
break;
34-
case IFACE_EVENT_STATUS_UP:
34+
case GR_EVENT_IFACE_STATUS_UP:
3535
assert(e->payload_len == sizeof(*p));
3636
p = PAYLOAD(e);
3737
printf("> iface up: %s\n", p->iface.name);
3838
break;
39-
case IFACE_EVENT_STATUS_DOWN:
39+
case GR_EVENT_IFACE_STATUS_DOWN:
4040
assert(e->payload_len == sizeof(*p));
4141
p = PAYLOAD(e);
4242
printf("> iface down: %s\n", p->iface.name);
4343
break;
44-
case IFACE_EVENT_POST_RECONFIG:
44+
case GR_EVENT_IFACE_POST_RECONFIG:
4545
assert(e->payload_len == sizeof(*p));
4646
p = PAYLOAD(e);
4747
printf("> iface reconf: %s\n", p->iface.name);
4848
break;
49-
case IP_EVENT_ADDR_ADD:
50-
case IP6_EVENT_ADDR_ADD:
49+
case GR_EVENT_IP_ADDR_ADD:
50+
case GR_EVENT_IP6_ADDR_ADD:
5151
assert(e->payload_len == sizeof(*nh));
5252
nh = PAYLOAD(e);
5353
printf("> addr add: iface[%d] " ADDR_F "\n",
5454
nh->iface_id,
5555
ADDR_W(nh_af(nh)),
5656
&nh->addr);
5757
break;
58-
case IP_EVENT_ADDR_DEL:
59-
case IP6_EVENT_ADDR_DEL:
58+
case GR_EVENT_IP_ADDR_DEL:
59+
case GR_EVENT_IP6_ADDR_DEL:
6060
assert(e->payload_len == sizeof(*nh));
6161
nh = PAYLOAD(e);
6262
printf("> addr del: iface[%d] " ADDR_F "\n",
6363
nh->iface_id,
6464
ADDR_W(nh_af(nh)),
6565
&nh->addr);
6666
break;
67-
case IP_EVENT_ROUTE_ADD:
67+
case GR_EVENT_IP_ROUTE_ADD:
6868
assert(e->payload_len == sizeof(*r4));
6969
r4 = PAYLOAD(e);
7070
printf("> route add: %4p/%d via %4p origin %s\n",
@@ -73,7 +73,7 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
7373
&r4->nh,
7474
gr_rt_origin_name(r4->origin));
7575
break;
76-
case IP_EVENT_ROUTE_DEL:
76+
case GR_EVENT_IP_ROUTE_DEL:
7777
assert(e->payload_len == sizeof(*r4));
7878
r4 = PAYLOAD(e);
7979
printf("> route del: %4p/%d via %4p origin %s\n",
@@ -82,7 +82,7 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
8282
&r4->nh,
8383
gr_rt_origin_name(r4->origin));
8484
break;
85-
case IP6_EVENT_ROUTE_ADD:
85+
case GR_EVENT_IP6_ROUTE_ADD:
8686
assert(e->payload_len == sizeof(*r6));
8787
r6 = PAYLOAD(e);
8888
printf("> route add: %6p/%d via %6p origin %s\n",
@@ -91,7 +91,7 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
9191
&r6->nh,
9292
gr_rt_origin_name(r6->origin));
9393
break;
94-
case IP6_EVENT_ROUTE_DEL:
94+
case GR_EVENT_IP6_ROUTE_DEL:
9595
assert(e->payload_len == sizeof(*r6));
9696
r6 = PAYLOAD(e);
9797
printf("> route del: %6p/%d via %6p origin %s\n",
@@ -100,7 +100,7 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
100100
&r6->nh,
101101
gr_rt_origin_name(r6->origin));
102102
break;
103-
case NEXTHOP_EVENT_NEW:
103+
case GR_EVENT_NEXTHOP_NEW:
104104
assert(e->payload_len == sizeof(*nh));
105105
nh = PAYLOAD(e);
106106
printf("> nh new: iface %d vrf %d " ADDR_F " " ETH_F "\n",
@@ -110,7 +110,7 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
110110
&nh->addr,
111111
&nh->mac);
112112
break;
113-
case NEXTHOP_EVENT_DELETE:
113+
case GR_EVENT_NEXTHOP_DELETE:
114114
assert(e->payload_len == sizeof(*nh));
115115
nh = PAYLOAD(e);
116116
printf("> nh del: iface %d vrf %d " ADDR_F " " ETH_F "\n",
@@ -120,7 +120,7 @@ static cmd_status_t events_show(const struct gr_api_client *c, const struct ec_p
120120
&nh->addr,
121121
&nh->mac);
122122
break;
123-
case NEXTHOP_EVENT_UPDATE:
123+
case GR_EVENT_NEXTHOP_UPDATE:
124124
assert(e->payload_len == sizeof(*nh));
125125
nh = PAYLOAD(e);
126126
printf("> nh update: iface %d vrf %d " ADDR_F " " ETH_F "\n",

modules/infra/control/iface.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct iface *iface_create(const struct gr_iface *conf, const void *api_info) {
8888

8989
ifaces[ifid] = iface;
9090

91-
gr_event_push(IFACE_EVENT_POST_ADD, iface);
91+
gr_event_push(GR_EVENT_IFACE_POST_ADD, iface);
9292

9393
return iface;
9494
fail:
@@ -247,9 +247,9 @@ int iface_destroy(uint16_t ifid) {
247247
/* interface is still up, send status down */
248248
if (iface->flags & GR_IFACE_F_UP) {
249249
iface->flags &= ~GR_IFACE_F_UP;
250-
gr_event_push(IFACE_EVENT_STATUS_DOWN, iface);
250+
gr_event_push(GR_EVENT_IFACE_STATUS_DOWN, iface);
251251
}
252-
gr_event_push(IFACE_EVENT_PRE_REMOVE, iface);
252+
gr_event_push(GR_EVENT_IFACE_PRE_REMOVE, iface);
253253

254254
ifaces[ifid] = NULL;
255255
type = iface_type_get(iface->type);
@@ -307,19 +307,19 @@ static void iface_event_debug(uint32_t event, const void *obj) {
307307
const struct iface *iface = obj;
308308
char *str = "";
309309
switch (event) {
310-
case IFACE_EVENT_POST_ADD:
310+
case GR_EVENT_IFACE_POST_ADD:
311311
str = "POST_ADD";
312312
break;
313-
case IFACE_EVENT_PRE_REMOVE:
313+
case GR_EVENT_IFACE_PRE_REMOVE:
314314
str = "PRE_REMOVE";
315315
break;
316-
case IFACE_EVENT_POST_RECONFIG:
316+
case GR_EVENT_IFACE_POST_RECONFIG:
317317
str = "POST_RECONFIG";
318318
break;
319-
case IFACE_EVENT_STATUS_UP:
319+
case GR_EVENT_IFACE_STATUS_UP:
320320
str = "STATUS_UP";
321321
break;
322-
case IFACE_EVENT_STATUS_DOWN:
322+
case GR_EVENT_IFACE_STATUS_DOWN:
323323
str = "STATUS_DOWN";
324324
break;
325325
default:
@@ -333,11 +333,11 @@ static struct gr_event_subscription iface_event_debug_handler = {
333333
.callback = iface_event_debug,
334334
.ev_count = 5,
335335
.ev_types = {
336-
IFACE_EVENT_POST_ADD,
337-
IFACE_EVENT_PRE_REMOVE,
338-
IFACE_EVENT_POST_RECONFIG,
339-
IFACE_EVENT_STATUS_UP,
340-
IFACE_EVENT_STATUS_DOWN,
336+
GR_EVENT_IFACE_POST_ADD,
337+
GR_EVENT_IFACE_PRE_REMOVE,
338+
GR_EVENT_IFACE_POST_RECONFIG,
339+
GR_EVENT_IFACE_STATUS_UP,
340+
GR_EVENT_IFACE_STATUS_DOWN,
341341
},
342342
};
343343

modules/infra/control/nexthop.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ nexthop_new(gr_nh_type_t type, uint16_t vrf_id, uint16_t iface_id, const void *a
132132
ABORT("invalid nexthop type %hhu", type);
133133
}
134134

135-
gr_event_push(NEXTHOP_EVENT_NEW, nh);
135+
gr_event_push(GR_EVENT_NEXTHOP_NEW, nh);
136136

137137
return nh;
138138
}
@@ -211,7 +211,7 @@ void nexthop_decref(struct nexthop *nh) {
211211
rte_pktmbuf_free(m);
212212
m = next;
213213
}
214-
gr_event_push(NEXTHOP_EVENT_DELETE, nh);
214+
gr_event_push(GR_EVENT_NEXTHOP_DELETE, nh);
215215
memset(nh, 0, sizeof(*nh));
216216
rte_mempool_put(pool, nh);
217217
} else {
@@ -301,9 +301,9 @@ static struct gr_event_serializer nh_serializer = {
301301
.size = sizeof(struct gr_nexthop),
302302
.ev_count = 3,
303303
.ev_types = {
304-
NEXTHOP_EVENT_NEW,
305-
NEXTHOP_EVENT_DELETE,
306-
NEXTHOP_EVENT_UPDATE,
304+
GR_EVENT_NEXTHOP_NEW,
305+
GR_EVENT_NEXTHOP_DELETE,
306+
GR_EVENT_NEXTHOP_UPDATE,
307307
},
308308
};
309309

modules/infra/control/port.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ static int iface_port_reconfig(
229229
if (conf->flags & GR_IFACE_F_UP) {
230230
ret = rte_eth_dev_set_link_up(p->port_id);
231231
iface->flags |= GR_IFACE_F_UP;
232-
gr_event_push(IFACE_EVENT_STATUS_UP, iface);
232+
gr_event_push(GR_EVENT_IFACE_STATUS_UP, iface);
233233
} else {
234234
ret = rte_eth_dev_set_link_down(p->port_id);
235235
iface->flags &= ~GR_IFACE_F_UP;
236-
gr_event_push(IFACE_EVENT_STATUS_DOWN, iface);
236+
gr_event_push(GR_EVENT_IFACE_STATUS_DOWN, iface);
237237
}
238238
if (ret < 0)
239239
errno_log(-ret, "rte_eth_dev_set_link_{up,down}");
@@ -272,7 +272,7 @@ static int iface_port_reconfig(
272272

273273
p->started = true;
274274

275-
gr_event_push(IFACE_EVENT_POST_RECONFIG, iface);
275+
gr_event_push(GR_EVENT_IFACE_POST_RECONFIG, iface);
276276

277277
return port_plug(p->port_id);
278278
}
@@ -601,13 +601,13 @@ static void link_event_cb(evutil_socket_t, short /*what*/, void * /*priv*/) {
601601
if (!(iface->state & GR_IFACE_S_RUNNING)) {
602602
LOG(INFO, "%s: link status up", iface->name);
603603
iface->state |= GR_IFACE_S_RUNNING;
604-
gr_event_push(IFACE_EVENT_STATUS_UP, iface);
604+
gr_event_push(GR_EVENT_IFACE_STATUS_UP, iface);
605605
}
606606
} else {
607607
if (iface->state & GR_IFACE_S_RUNNING) {
608608
LOG(INFO, "%s: link status down", iface->name);
609609
iface->state &= ~GR_IFACE_S_RUNNING;
610-
gr_event_push(IFACE_EVENT_STATUS_DOWN, iface);
610+
gr_event_push(GR_EVENT_IFACE_STATUS_DOWN, iface);
611611
}
612612
continue;
613613
}

modules/infra/control/vlan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int iface_vlan_reconfig(
128128
if (set_attrs & GR_IFACE_SET_VRF)
129129
iface->vrf_id = conf->vrf_id;
130130

131-
gr_event_push(IFACE_EVENT_POST_RECONFIG, iface);
131+
gr_event_push(GR_EVENT_IFACE_POST_RECONFIG, iface);
132132

133133
return 0;
134134
}
@@ -273,7 +273,7 @@ static void port_event(uint32_t event, const void *obj) {
273273
while ((vlan = iface_next(GR_IFACE_TYPE_VLAN, vlan)) != NULL) {
274274
info = (struct iface_info_vlan *)vlan->info;
275275
if (info->parent_id == iface->id) {
276-
if (event == IFACE_EVENT_STATUS_UP) {
276+
if (event == GR_EVENT_IFACE_STATUS_UP) {
277277
vlan->flags |= GR_IFACE_F_UP;
278278
vlan->state |= GR_IFACE_S_RUNNING;
279279
} else {
@@ -288,7 +288,7 @@ static void port_event(uint32_t event, const void *obj) {
288288
static struct gr_event_subscription port_event_sub = {
289289
.callback = port_event,
290290
.ev_count = 2,
291-
.ev_types = {IFACE_EVENT_STATUS_UP, IFACE_EVENT_STATUS_DOWN},
291+
.ev_types = {GR_EVENT_IFACE_STATUS_UP, GR_EVENT_IFACE_STATUS_DOWN},
292292
};
293293

294294
RTE_INIT(vlan_constructor) {

modules/infra/control/vrf.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ static void iface_event_vrf(uint32_t event, const void *obj) {
2929
return;
3030

3131
switch (event) {
32-
case IFACE_EVENT_POST_ADD:
32+
case GR_EVENT_IFACE_POST_ADD:
3333
if (++vrfs[iface->vrf_id].ref_count == 1)
3434
vrfs[iface->vrf_id].iface = iface_loopback_create(iface->vrf_id);
3535
break;
36-
case IFACE_EVENT_PRE_REMOVE:
36+
case GR_EVENT_IFACE_PRE_REMOVE:
3737
if (--vrfs[iface->vrf_id].ref_count == 0) {
3838
iface_loopback_delete(iface->vrf_id);
3939
vrfs[iface->vrf_id].iface = NULL;
4040
}
4141
break;
42-
case IFACE_EVENT_POST_RECONFIG:
42+
case GR_EVENT_IFACE_POST_RECONFIG:
4343
iface = NULL;
4444
while ((iface = iface_next(GR_IFACE_TYPE_UNDEF, iface)) != NULL) {
4545
if (iface->type == GR_IFACE_TYPE_LOOPBACK)
@@ -68,9 +68,9 @@ static struct gr_event_subscription iface_event_vrf_sub = {
6868
.callback = iface_event_vrf,
6969
.ev_count = 3,
7070
.ev_types = {
71-
IFACE_EVENT_POST_ADD,
72-
IFACE_EVENT_PRE_REMOVE,
73-
IFACE_EVENT_POST_RECONFIG,
71+
GR_EVENT_IFACE_POST_ADD,
72+
GR_EVENT_IFACE_PRE_REMOVE,
73+
GR_EVENT_IFACE_POST_RECONFIG,
7474
},
7575
};
7676

0 commit comments

Comments
 (0)