Skip to content

Commit ac5a3d5

Browse files
committed
gtp_interface_rule: rename to gtp_bpf_ifrules
Signed-off-by: Olivier Gournet <gournet.olivier@gmail.com>
1 parent 0054321 commit ac5a3d5

File tree

13 files changed

+72
-68
lines changed

13 files changed

+72
-68
lines changed

src/carrier-grade-nat/cgn.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "gtp_data.h"
4141
#include "gtp_bpf_prog.h"
4242
#include "gtp_interface.h"
43-
#include "gtp_interface_rule.h"
4443
#include "cdr_fwd.h"
4544
#include "cgn.h"
4645
#include "bpf/lib/cgn-def.h"

src/carrier-grade-nat/cgn_bpf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "gtp_data.h"
4545
#include "gtp_bpf_prog.h"
4646
#include "gtp_interface.h"
47-
#include "gtp_interface_rule.h"
4847
#include "cgn.h"
4948
#include "bpf/lib/cgn-def.h"
5049
#include "bpf/lib/flow-def.h"

src/gtp_bpf_fwd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ gtp_bpf_fwd_release(struct gtp_bpf_prog *p, void *udata)
272272
list_for_each_entry_safe(proxy, tmp, &pf->gtp_proxy_list, bpf_list) {
273273
proxy->bpf_prog = NULL;
274274
proxy->bpf_data = NULL;
275-
proxy->bpf_irules = NULL;
275+
proxy->bpf_ifrules = NULL;
276276
list_del_init(&proxy->bpf_list);
277277
}
278278
free(pf);
Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/* local includes */
2525
#include "gtp_interface.h"
26+
#include "gtp_bpf_irules.h"
2627
#include "gtp_bpf_utils.h"
2728
#include "utils.h"
2829
#include "jhash.h"
@@ -51,7 +52,7 @@ struct output_rule {
5152
};
5253

5354
/* bpf data, per bpf program */
54-
struct gtp_bpf_interface_rule {
55+
struct gtp_bpf_irules {
5556
struct bpf_map *if_rule;
5657
struct bpf_map *if_rule_attr;
5758

@@ -69,7 +70,7 @@ struct gtp_bpf_interface_rule {
6970

7071

7172

72-
static inline struct gtp_bpf_interface_rule *
73+
static inline struct gtp_bpf_irules *
7374
_get_bir(struct gtp_interface *iface, int *ifindex)
7475
{
7576
/* retrieve 'physical' interface, where bpf map are located */
@@ -110,7 +111,7 @@ _rule_hash(const struct gtp_if_rule *r)
110111
}
111112

112113
static inline struct stored_rule *
113-
_rule_find(struct gtp_bpf_interface_rule *bir, const struct gtp_if_rule *r)
114+
_rule_find(struct gtp_bpf_irules *bir, const struct gtp_if_rule *r)
114115
{
115116
struct stored_rule *sr;
116117
uint32_t h = _rule_hash(r);
@@ -126,7 +127,7 @@ _rule_find(struct gtp_bpf_interface_rule *bir, const struct gtp_if_rule *r)
126127
}
127128

128129
static inline struct stored_rule *
129-
_rule_find_first(struct gtp_bpf_interface_rule *bir, const struct gtp_if_rule *r,
130+
_rule_find_first(struct gtp_bpf_irules *bir, const struct gtp_if_rule *r,
130131
uint32_t h)
131132
{
132133
struct stored_rule *sr;
@@ -139,7 +140,7 @@ _rule_find_first(struct gtp_bpf_interface_rule *bir, const struct gtp_if_rule *r
139140
}
140141

141142
static struct stored_rule *
142-
_rule_find_next(struct gtp_bpf_interface_rule *bir, const struct gtp_if_rule *r,
143+
_rule_find_next(struct gtp_bpf_irules *bir, const struct gtp_if_rule *r,
143144
uint32_t h, struct stored_rule *sr)
144145
{
145146
hlist_for_each_entry_continue(sr, hlist) {
@@ -150,7 +151,7 @@ _rule_find_next(struct gtp_bpf_interface_rule *bir, const struct gtp_if_rule *r,
150151
}
151152

152153
static struct stored_rule *
153-
_rule_store(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r)
154+
_rule_store(struct gtp_bpf_irules *bir, struct gtp_if_rule *r)
154155
{
155156
uint32_t h = jhash(r->key, r->key_size, 0) % IF_RULE_MAX_RULE;
156157
struct stored_rule *sr;
@@ -176,7 +177,7 @@ _rule_del(struct stored_rule *sr)
176177
}
177178

178179
static int
179-
_rule_set_key_base(struct gtp_bpf_interface_rule *bir, int ifindex, struct gtp_if_rule *r)
180+
_rule_set_key_base(struct gtp_bpf_irules *bir, int ifindex, struct gtp_if_rule *r)
180181
{
181182
struct if_rule_key_base *k;
182183

@@ -242,7 +243,7 @@ _rule_set_attr(struct gtp_interface *iface, struct if_rule_attr *a)
242243
}
243244

244245
static int
245-
_rule_install(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r,
246+
_rule_install(struct gtp_bpf_irules *bir, struct gtp_if_rule *r,
246247
bool overwrite)
247248
{
248249
uint32_t nr_cpus = bpf_num_possible_cpus();
@@ -278,7 +279,7 @@ _rule_install(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r,
278279
}
279280

280281
static void
281-
_rule_uninstall(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r)
282+
_rule_uninstall(struct gtp_bpf_irules *bir, struct gtp_if_rule *r)
282283
{
283284
int ret;
284285

@@ -288,7 +289,7 @@ _rule_uninstall(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r)
288289
}
289290

290291
static int
291-
_if_rule_add(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r, int ifindex)
292+
_if_rule_add(struct gtp_bpf_irules *bir, struct gtp_if_rule *r, int ifindex)
292293
{
293294
struct stored_rule *sr;
294295
int ret = -1;
@@ -319,7 +320,7 @@ _if_rule_add(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r, int ifin
319320

320321

321322
static void
322-
_if_rule_del(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r, int ifindex)
323+
_if_rule_del(struct gtp_bpf_irules *bir, struct gtp_if_rule *r, int ifindex)
323324
{
324325
struct stored_rule *sr;
325326

@@ -335,9 +336,9 @@ _if_rule_del(struct gtp_bpf_interface_rule *bir, struct gtp_if_rule *r, int ifin
335336
}
336337

337338
int
338-
gtp_interface_rule_set(struct gtp_if_rule *r, bool add)
339+
gtp_bpf_irules_set(struct gtp_if_rule *r, bool add)
339340
{
340-
struct gtp_bpf_interface_rule *bir = r->bir;
341+
struct gtp_bpf_irules *bir = r->bir;
341342
int ifindex = 0;
342343

343344
if (bir == NULL) {
@@ -357,7 +358,7 @@ gtp_interface_rule_set(struct gtp_if_rule *r, bool add)
357358
static void
358359
_rule_del_iface(struct gtp_interface *iface)
359360
{
360-
struct gtp_bpf_interface_rule *bir;
361+
struct gtp_bpf_irules *bir;
361362
struct stored_rule *sr, *sr_tmp;
362363

363364
bir = _get_bir(iface, NULL);
@@ -394,7 +395,7 @@ _out_rule_sort_cb(struct list_head *al, struct list_head *bl)
394395

395396

396397
static void
397-
_out_rule_attr_add(struct gtp_bpf_interface_rule *bir, struct gtp_interface *iface)
398+
_out_rule_attr_add(struct gtp_bpf_irules *bir, struct gtp_interface *iface)
398399
{
399400
struct output_rule *or;
400401
struct if_rule_attr a;
@@ -433,7 +434,7 @@ _out_rule_attr_add(struct gtp_bpf_interface_rule *bir, struct gtp_interface *ifa
433434
}
434435

435436
static void
436-
_out_rule_attr_del(struct gtp_bpf_interface_rule *bir, struct gtp_interface *iface)
437+
_out_rule_attr_del(struct gtp_bpf_irules *bir, struct gtp_interface *iface)
437438
{
438439
struct output_rule *or;
439440
int ifindex, ret;
@@ -466,7 +467,7 @@ static void
466467
_out_rule_event_cb(struct gtp_interface *iface, enum gtp_interface_event type,
467468
void *udata, void *arg)
468469
{
469-
struct gtp_bpf_interface_rule *bir = udata;
470+
struct gtp_bpf_irules *bir = udata;
470471
struct gtp_interface *child = arg;
471472
bool def_route = !__test_bit(GTP_INTERFACE_FL_BFP_NO_DEFAULT_ROUTE_BIT,
472473
&child->flags);
@@ -490,10 +491,10 @@ _out_rule_event_cb(struct gtp_interface *iface, enum gtp_interface_event type,
490491
}
491492

492493
void
493-
gtp_interface_rule_set_auto_input_rule(struct gtp_interface *iface, bool set)
494+
gtp_bpf_irules_set_auto_input_rule(struct gtp_interface *iface, bool set)
494495
{
495496
struct gtp_interface *master = iface->link_iface ?: iface;
496-
struct gtp_bpf_interface_rule *bir = master->bpf_irules;
497+
struct gtp_bpf_irules *bir = master->bpf_irules;
497498

498499
if (bir == NULL)
499500
return;
@@ -516,7 +517,7 @@ gtp_interface_rule_set_auto_input_rule(struct gtp_interface *iface, bool set)
516517
*/
517518

518519
static void
519-
gtp_ifrule_vty_output(struct gtp_bpf_interface_rule *bir, struct vty *vty)
520+
gtp_ifrule_vty_output(struct gtp_bpf_irules *bir, struct vty *vty)
520521
{
521522
struct gtp_interface *to;
522523
struct if_rule_attr a;
@@ -589,7 +590,7 @@ gtp_ifrule_vty_output(struct gtp_bpf_interface_rule *bir, struct vty *vty)
589590
}
590591

591592
static void
592-
gtp_ifrule_vty_all(struct gtp_bpf_interface_rule *bir, struct vty *vty)
593+
gtp_ifrule_vty_all(struct gtp_bpf_irules *bir, struct vty *vty)
593594
{
594595
struct gtp_interface *from = NULL;
595596
struct if_rule_key_base *k;
@@ -650,7 +651,7 @@ gtp_ifrule_vty_all(struct gtp_bpf_interface_rule *bir, struct vty *vty)
650651
}
651652

652653
static void
653-
gtp_ifrule_vty_input(struct gtp_bpf_interface_rule *bir, struct vty *vty)
654+
gtp_ifrule_vty_input(struct gtp_bpf_irules *bir, struct vty *vty)
654655
{
655656
unsigned int nr_cpus = bpf_num_possible_cpus();
656657
struct if_rule aar[nr_cpus];
@@ -743,7 +744,7 @@ static void
743744
gtp_ifrule_vty(struct gtp_bpf_prog *p, void *ud, struct vty *vty,
744745
int argc, const char **argv)
745746
{
746-
struct gtp_bpf_interface_rule *bir = ud;
747+
struct gtp_bpf_irules *bir = ud;
747748

748749
if (bir->if_rule == NULL)
749750
return;
@@ -760,7 +761,7 @@ gtp_ifrule_vty(struct gtp_bpf_prog *p, void *ud, struct vty *vty,
760761
static int
761762
gtp_ifrule_loaded(struct gtp_bpf_prog *p, void *udata, bool reload)
762763
{
763-
struct gtp_bpf_interface_rule *bir = udata;
764+
struct gtp_bpf_irules *bir = udata;
764765

765766
bir->if_rule = gtp_bpf_prog_load_map(p->load.obj, "if_rule");
766767
bir->if_rule_attr = gtp_bpf_prog_load_map(p->load.obj, "if_rule_attr");
@@ -780,7 +781,7 @@ gtp_ifrule_loaded(struct gtp_bpf_prog *p, void *udata, bool reload)
780781
static int
781782
gtp_ifrule_bind_itf(struct gtp_bpf_prog *p, void *udata, struct gtp_interface *iface)
782783
{
783-
struct gtp_bpf_interface_rule *bir = udata;
784+
struct gtp_bpf_irules *bir = udata;
784785

785786
iface->bpf_irules = bir;
786787

@@ -792,7 +793,7 @@ gtp_ifrule_bind_itf(struct gtp_bpf_prog *p, void *udata, struct gtp_interface *i
792793
static void
793794
gtp_ifrule_unbind_itf(struct gtp_bpf_prog *p, void *udata, struct gtp_interface *iface)
794795
{
795-
struct gtp_bpf_interface_rule *bir = udata;
796+
struct gtp_bpf_irules *bir = udata;
796797

797798
gtp_interface_unregister_event(iface, _out_rule_event_cb, bir);
798799
_rule_del_iface(iface);
@@ -803,9 +804,9 @@ gtp_ifrule_unbind_itf(struct gtp_bpf_prog *p, void *udata, struct gtp_interface
803804
static void *
804805
gtp_ifrule_alloc(struct gtp_bpf_prog *p)
805806
{
806-
struct gtp_bpf_interface_rule *bir;
807+
struct gtp_bpf_irules *bir;
807808

808-
bir = calloc(1, sizeof (struct gtp_bpf_interface_rule));
809+
bir = calloc(1, sizeof (struct gtp_bpf_irules));
809810
INIT_LIST_HEAD(&bir->rule_list);
810811
INIT_LIST_HEAD(&bir->out_rule_list);
811812
return bir;
@@ -814,7 +815,7 @@ gtp_ifrule_alloc(struct gtp_bpf_prog *p)
814815
static void
815816
gtp_ifrule_release(struct gtp_bpf_prog *p, void *udata)
816817
{
817-
struct gtp_bpf_interface_rule *bir = udata;
818+
struct gtp_bpf_irules *bir = udata;
818819
struct stored_rule *sr, *sr_tmp;
819820
struct output_rule *or, *or_tmp;
820821

@@ -827,7 +828,7 @@ gtp_ifrule_release(struct gtp_bpf_prog *p, void *udata)
827828
}
828829

829830

830-
static struct gtp_bpf_prog_tpl gtp_interface_rule_module = {
831+
static struct gtp_bpf_prog_tpl gtp_bpf_irules_module = {
831832
.name = "if_rules",
832833
.description = "Interface rules dispatcher",
833834
.alloc = gtp_ifrule_alloc,
@@ -839,7 +840,7 @@ static struct gtp_bpf_prog_tpl gtp_interface_rule_module = {
839840
};
840841

841842
static void __attribute__((constructor))
842-
gtp_interface_rule_init(void)
843+
gtp_bpf_irules_init(void)
843844
{
844-
gtp_bpf_prog_tpl_register(&gtp_interface_rule_module);
845+
gtp_bpf_prog_tpl_register(&gtp_bpf_irules_module);
845846
}

src/gtp_interface_vty.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "gtp_data.h"
2626
#include "gtp_bpf_prog.h"
2727
#include "gtp_bpf_rt.h"
28+
#include "gtp_bpf_ifrules.h"
2829
#include "gtp_interface.h"
2930
#include "inet_utils.h"
3031
#include "command.h"
@@ -213,7 +214,7 @@ DEFUN(interface_bpf_pkt,
213214
else
214215
__set_bit(GTP_INTERFACE_FL_BFP_NO_DEFAULT_ROUTE_BIT, &iface->flags);
215216

216-
gtp_interface_rule_set_auto_input_rule(iface, set);
217+
gtp_bpf_ifrules_set_auto_input_rule(iface, set);
217218

218219
return CMD_SUCCESS;
219220
}

0 commit comments

Comments
 (0)