Skip to content

Commit dc1cbd1

Browse files
ecsvsimonwunderlich
authored andcommitted
batman-adv: Allow to disable debugfs support
The files provided by batman-adv via debugfs are currently converted to netlink. Tools which are not yet converted to use the netlink interface may still rely on the old debugfs files. But systems which already upgraded their tools can save some space by disabling this feature. The default configuration of batman-adv on amd64 can reduce the size of the module by around 11% when this feature is disabled. $ size net/batman-adv/batman-adv.ko* text data bss dec hex filename 150507 10395 4160 165062 284c6 net/batman-adv/batman-adv.ko.y 137106 7099 2112 146317 23b8d net/batman-adv/batman-adv.ko.n Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
1 parent 06d640c commit dc1cbd1

16 files changed

Lines changed: 87 additions & 6 deletions

‎net/batman-adv/Kconfig‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,21 @@ config BATMAN_ADV_MCAST
7373
reduce the air overhead while improving the reliability of
7474
multicast messages.
7575

76-
config BATMAN_ADV_DEBUG
77-
bool "B.A.T.M.A.N. debugging"
76+
config BATMAN_ADV_DEBUGFS
77+
bool "batman-adv debugfs entries"
7878
depends on BATMAN_ADV
7979
depends on DEBUG_FS
80+
default y
81+
help
82+
Enable this to export routing related debug tables via debugfs.
83+
The information for each soft-interface and used hard-interface can be
84+
found under batman_adv/
85+
86+
If unsure, say Y.
87+
88+
config BATMAN_ADV_DEBUG
89+
bool "B.A.T.M.A.N. debugging"
90+
depends on BATMAN_ADV_DEBUGFS
8091
help
8192
This is an option for use by developers; most people should
8293
say N here. This enables compilation of support for

‎net/batman-adv/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o
2424
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o
2525
batman-adv-y += bitarray.o
2626
batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
27-
batman-adv-$(CONFIG_DEBUG_FS) += debugfs.o
27+
batman-adv-$(CONFIG_BATMAN_ADV_DEBUGFS) += debugfs.o
2828
batman-adv-$(CONFIG_BATMAN_ADV_DAT) += distributed-arp-table.o
2929
batman-adv-y += fragmentation.o
3030
batman-adv-y += gateway_client.o
3131
batman-adv-y += gateway_common.o
3232
batman-adv-y += hard-interface.o
3333
batman-adv-y += hash.o
34-
batman-adv-y += icmp_socket.o
34+
batman-adv-$(CONFIG_BATMAN_ADV_DEBUGFS) += icmp_socket.o
3535
batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o
3636
batman-adv-y += main.o
3737
batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o

‎net/batman-adv/bat_algo.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
101101
return 0;
102102
}
103103

104+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
104105
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
105106
{
106107
struct batadv_algo_ops *bat_algo_ops;
@@ -113,6 +114,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
113114

114115
return 0;
115116
}
117+
#endif
116118

117119
static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
118120
{

‎net/batman-adv/bat_iv_ogm.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
18551855
return NET_RX_SUCCESS;
18561856
}
18571857

1858+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
18581859
/**
18591860
* batadv_iv_ogm_orig_print_neigh - print neighbors for the originator table
18601861
* @orig_node: the orig_node for which the neighbors are printed
@@ -1952,6 +1953,7 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
19521953
if (batman_count == 0)
19531954
seq_puts(seq, "No batman nodes in range ...\n");
19541955
}
1956+
#endif
19551957

19561958
/**
19571959
* batadv_iv_ogm_neigh_get_tq_avg - Get the TQ average for a neighbour on a
@@ -2182,6 +2184,7 @@ batadv_iv_ogm_orig_dump(struct sk_buff *msg, struct netlink_callback *cb,
21822184
cb->args[2] = sub;
21832185
}
21842186

2187+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
21852188
/**
21862189
* batadv_iv_hardif_neigh_print - print a single hop neighbour node
21872190
* @seq: neighbour table seq_file struct
@@ -2232,6 +2235,7 @@ static void batadv_iv_neigh_print(struct batadv_priv *bat_priv,
22322235
if (batman_count == 0)
22332236
seq_puts(seq, "No batman nodes in range ...\n");
22342237
}
2238+
#endif
22352239

22362240
/**
22372241
* batadv_iv_ogm_neigh_diff - calculate tq difference of two neighbors
@@ -2618,6 +2622,7 @@ static bool batadv_iv_gw_is_eligible(struct batadv_priv *bat_priv,
26182622
return ret;
26192623
}
26202624

2625+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
26212626
/* fails if orig_node has no router */
26222627
static int batadv_iv_gw_write_buffer_text(struct batadv_priv *bat_priv,
26232628
struct seq_file *seq,
@@ -2681,6 +2686,7 @@ static void batadv_iv_gw_print(struct batadv_priv *bat_priv,
26812686
if (gw_count == 0)
26822687
seq_puts(seq, "No gateways in range ...\n");
26832688
}
2689+
#endif
26842690

26852691
/**
26862692
* batadv_iv_gw_dump_entry - Dump a gateway into a message
@@ -2798,11 +2804,15 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
27982804
.neigh = {
27992805
.cmp = batadv_iv_ogm_neigh_cmp,
28002806
.is_similar_or_better = batadv_iv_ogm_neigh_is_sob,
2807+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
28012808
.print = batadv_iv_neigh_print,
2809+
#endif
28022810
.dump = batadv_iv_ogm_neigh_dump,
28032811
},
28042812
.orig = {
2813+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
28052814
.print = batadv_iv_ogm_orig_print,
2815+
#endif
28062816
.dump = batadv_iv_ogm_orig_dump,
28072817
.free = batadv_iv_ogm_orig_free,
28082818
.add_if = batadv_iv_ogm_orig_add_if,
@@ -2811,7 +2821,9 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
28112821
.gw = {
28122822
.get_best_gw_node = batadv_iv_gw_get_best_gw_node,
28132823
.is_eligible = batadv_iv_gw_is_eligible,
2824+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
28142825
.print = batadv_iv_gw_print,
2826+
#endif
28152827
.dump = batadv_iv_gw_dump,
28162828
},
28172829
};

‎net/batman-adv/bat_v.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh)
129129
batadv_v_elp_throughput_metric_update);
130130
}
131131

132+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
132133
/**
133134
* batadv_v_orig_print_neigh - print neighbors for the originator table
134135
* @orig_node: the orig_node for which the neighbors are printed
@@ -212,6 +213,7 @@ static void batadv_v_neigh_print(struct batadv_priv *bat_priv,
212213
if (batman_count == 0)
213214
seq_puts(seq, "No batman nodes in range ...\n");
214215
}
216+
#endif
215217

216218
/**
217219
* batadv_v_neigh_dump_neigh - Dump a neighbour into a message
@@ -345,6 +347,7 @@ batadv_v_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb,
345347
cb->args[1] = idx;
346348
}
347349

350+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
348351
/**
349352
* batadv_v_orig_print - print the originator table
350353
* @bat_priv: the bat priv with all the soft interface information
@@ -411,6 +414,7 @@ static void batadv_v_orig_print(struct batadv_priv *bat_priv,
411414
if (batman_count == 0)
412415
seq_puts(seq, "No batman nodes in range ...\n");
413416
}
417+
#endif
414418

415419
/**
416420
* batadv_v_orig_dump_subentry - Dump an originator subentry into a
@@ -827,6 +831,7 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv,
827831
return ret;
828832
}
829833

834+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
830835
/* fails if orig_node has no router */
831836
static int batadv_v_gw_write_buffer_text(struct batadv_priv *bat_priv,
832837
struct seq_file *seq,
@@ -896,6 +901,7 @@ static void batadv_v_gw_print(struct batadv_priv *bat_priv,
896901
if (gw_count == 0)
897902
seq_puts(seq, "No gateways in range ...\n");
898903
}
904+
#endif
899905

900906
/**
901907
* batadv_v_gw_dump_entry - Dump a gateway into a message
@@ -1034,19 +1040,25 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
10341040
.hardif_init = batadv_v_hardif_neigh_init,
10351041
.cmp = batadv_v_neigh_cmp,
10361042
.is_similar_or_better = batadv_v_neigh_is_sob,
1043+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
10371044
.print = batadv_v_neigh_print,
1045+
#endif
10381046
.dump = batadv_v_neigh_dump,
10391047
},
10401048
.orig = {
1049+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
10411050
.print = batadv_v_orig_print,
1051+
#endif
10421052
.dump = batadv_v_orig_dump,
10431053
},
10441054
.gw = {
10451055
.store_sel_class = batadv_v_store_sel_class,
10461056
.show_sel_class = batadv_v_show_sel_class,
10471057
.get_best_gw_node = batadv_v_gw_get_best_gw_node,
10481058
.is_eligible = batadv_v_gw_is_eligible,
1059+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
10491060
.print = batadv_v_gw_print,
1061+
#endif
10501062
.dump = batadv_v_gw_dump,
10511063
},
10521064
};

‎net/batman-adv/bridge_loop_avoidance.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,7 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
19961996
return ret;
19971997
}
19981998

1999+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
19992000
/**
20002001
* batadv_bla_claim_table_seq_print_text - print the claim table in a seq file
20012002
* @seq: seq file to print on
@@ -2056,6 +2057,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
20562057
batadv_hardif_put(primary_if);
20572058
return 0;
20582059
}
2060+
#endif
20592061

20602062
/**
20612063
* batadv_bla_claim_dump_entry - dump one entry of the claim table
@@ -2219,6 +2221,7 @@ int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb)
22192221
return ret;
22202222
}
22212223

2224+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
22222225
/**
22232226
* batadv_bla_backbone_table_seq_print_text - print the backbone table in a seq
22242227
* file
@@ -2282,6 +2285,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
22822285
batadv_hardif_put(primary_if);
22832286
return 0;
22842287
}
2288+
#endif
22852289

22862290
/**
22872291
* batadv_bla_backbone_dump_entry - dump one entry of the backbone table

‎net/batman-adv/debugfs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct net_device;
2626

2727
#define BATADV_DEBUGFS_SUBDIR "batman_adv"
2828

29-
#if IS_ENABLED(CONFIG_DEBUG_FS)
29+
#if IS_ENABLED(CONFIG_BATMAN_ADV_DEBUGFS)
3030

3131
void batadv_debugfs_init(void);
3232
void batadv_debugfs_destroy(void);

‎net/batman-adv/distributed-arp-table.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ void batadv_dat_free(struct batadv_priv *bat_priv)
795795
batadv_dat_hash_free(bat_priv);
796796
}
797797

798+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
798799
/**
799800
* batadv_dat_cache_seq_print_text - print the local DAT hash table
800801
* @seq: seq file to print on
@@ -846,6 +847,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
846847
batadv_hardif_put(primary_if);
847848
return 0;
848849
}
850+
#endif
849851

850852
/**
851853
* batadv_arp_get_type - parse an ARP packet and gets the type

‎net/batman-adv/gateway_client.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv)
482482
spin_unlock_bh(&bat_priv->gw.list_lock);
483483
}
484484

485+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
485486
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
486487
{
487488
struct net_device *net_dev = (struct net_device *)seq->private;
@@ -509,6 +510,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
509510

510511
return 0;
511512
}
513+
#endif
512514

513515
/**
514516
* batadv_gw_dump - Dump gateways into a message

‎net/batman-adv/icmp_socket.h‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,25 @@ struct batadv_icmp_header;
2626

2727
#define BATADV_ICMP_SOCKET "socket"
2828

29-
void batadv_socket_init(void);
3029
int batadv_socket_setup(struct batadv_priv *bat_priv);
30+
31+
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
32+
33+
void batadv_socket_init(void);
3134
void batadv_socket_receive_packet(struct batadv_icmp_header *icmph,
3235
size_t icmp_len);
3336

37+
#else
38+
39+
static inline void batadv_socket_init(void)
40+
{
41+
}
42+
43+
static inline void
44+
batadv_socket_receive_packet(struct batadv_icmp_header *icmph, size_t icmp_len)
45+
{
46+
}
47+
48+
#endif
49+
3450
#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */

0 commit comments

Comments
 (0)