batctl: Allow to configure routing_algo during interface creation
PATCH 1/1 batctl: Allow to configure routing_algo during interface creation
A batadv net_device is associated to a B.A.T.M.A.N. routing algorithm. This algorithm has to be selected before the interface is initialized and cannot be changed after that. The only way to select this algorithm was a module parameter which specifies the default algorithm used during the creation of the net_device.
This module parameter is writeable over /sys/module/batman_adv/parameters/routing_algo and thus allows switching of the routing algorithm:
1. change routing_algo parameter
2. create new batadv net_device
But this is not race free because another process can be scheduled between 1 + 2 and in that time frame change the routing_algo parameter again.
It is much cleaner to directly provide this information inside the rtnetlink's RTM_NEWLINK message. The two processes would be (in regards of the creation parameter of their batadv interfaces) be isolated.
This can now be done (with a compatible kernel module) using the routing_algo parameter of interface create:
$ batctl meshif bat0 interface create routing_algo BATMAN_IV or $ batctl meshif bat0 interface create routing_algo BATMAN_V
---
This version uses a parameter like ip-link. Another option to implement it would be to use some kind of --routing_algo option like the -M option which already exists. Maybe some people have a preference how the commandline interface should look like.
batman_adv.h | 26 ++++++++++++++++++++ interface.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++---- man/batctl.8 | 8 +++--- 3 files changed, 95 insertions(+), 8 deletions(-)
batman_adv.h +26 -0
@@ -675,4 +675,30 @@ enum batadv_tp_meter_reason { BATADV_TP_REASON_TOO_MANY = 133, }; +/** +* enum batadv_ifla_attrs - batman-adv ifla nested attributes +*/ +enum batadv_ifla_attrs { +/** +* @IFLA_BATADV_UNSPEC: unspecified attribute which is not parsed by +* rtnetlink +*/ +IFLA_BATADV_UNSPEC , + +/** +* @IFLA_BATADV_ALGO_NAME: routing algorithm (name) which should be +* used by the newly registered batadv net_device. +*/ +IFLA_BATADV_ALGO_NAME , + +/* add attributes above here, update the policy in soft-interface.c */ + +/** +* @__IFLA_BATADV_MAX: internal use +*/ + __IFLA_BATADV_MAX, +}; + +#define IFLA_BATADV_MAX (__IFLA_BATADV_MAX - 1) +#endif /* _UAPI_LINUX_BATMAN_ADV_H_ */
interface.c +64 -5
122 lines not on this page · raw message
man/batctl.8 +5 -3
@@ -60,9 +60,11 @@ In order to add or delete interfaces specify "add" or "del" as first argument an add or delete. Multiple interfaces can be specified. The "\-M" option tells batctl to not automatically create the batman-adv interface on "add". It can also be used to suppress the warning about the manual destruction when "del" removed all interfaces which belonged to it. -.IP "[\fBmeshif <netdev>\fP] \fBinterface\fP|\fBif\fP [\fBcreate\fP|\fBdestroy\fP]" -A batman-adv interface without attached interfaces can be created using "create". The parameter "destroy" can be used to -free all attached interfaces and remove batman-adv interface. +.IP "[\fBmeshif <netdev>\fP] \fBinterface\fP|\fBif\fP \fBcreate\fP [\fBrouting_algo|ra RA_NAME\fP]" +A batman-adv interface without attached interfaces can be created using "create". The parameter routing_algo +can be used to overwrite the (default) routing algorithm. +.IP "[\fBmeshif <netdev>\fP] \fBinterface\fP|\fBif\fP \fBdestroy\fP" +Remove all attached interfaces and destroy the batman-adv interface. .br .IP "[\fBmeshif <netdev>\fP] \fBorig_interval\fP|\fBit\fP [\fBinterval\fP]" If no parameter is given the current originator interval setting is displayed otherwise the parameter is used to set the
Signature · 1 line
2.28.0