r1615 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-03-30 04:08:05 +0200 (Tue, 30 Mar 2010)
New Revision: 1615
Modified:
trunk/batman-adv-kernelland/device.c
Log:
batman-adv: cleanup: change test for end of array
The code here is testing to see if "i" is passed the end of the array.
The original code works probably, but it's not the cleanest way.
Andrew Lunn suggested that I also remove all the hard coded references
to 256 so I have done that as well.
Signed-off-by: Dan Carpenter <error27(a)gmail.com>
Modified: trunk/batman-adv-kernelland/device.c
===================================================================
--- trunk/batman-adv-kernelland/device.c 2010-03-25 01:39:32 UTC (rev 1614)
+++ trunk/batman-adv-kernelland/device.c 2010-03-30 02:08:05 UTC (rev 1615)
@@ -45,10 +45,7 @@
void bat_device_init(void)
{
- int i;
-
- for (i = 0; i < 256; i++)
- device_client_hash[i] = NULL;
+ memset(device_client_hash, 0, sizeof(device_client_hash));
}
int bat_device_setup(void)
@@ -104,15 +101,15 @@
if (!device_client)
return -ENOMEM;
- for (i = 0; i < 256; i++) {
+ for (i = 0; i < ARRAY_SIZE(device_client_hash); i++) {
if (!device_client_hash[i]) {
device_client_hash[i] = device_client;
break;
}
}
- if (device_client_hash[i] != device_client) {
- printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached \n");
+ if (i == ARRAY_SIZE(device_client_hash)) {
+ printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
kfree(device_client);
return -EXFULL;
}
11 years
r1614 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-03-25 02:39:32 +0100 (Thu, 25 Mar 2010)
New Revision: 1614
Modified:
trunk/batman-adv-kernelland/gateway_client.c
trunk/batman-adv-kernelland/gateway_client.h
trunk/batman-adv-kernelland/routing.c
Log:
batman-adv: fix gateway selection
The sysfs conversion left some global variables which were not
properly removed and made a gateway selection impossible. This
patch fixes that.
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv-kernelland/gateway_client.c
===================================================================
--- trunk/batman-adv-kernelland/gateway_client.c 2010-03-22 22:30:52 UTC (rev 1613)
+++ trunk/batman-adv-kernelland/gateway_client.c 2010-03-25 01:39:32 UTC (rev 1614)
@@ -31,7 +31,6 @@
static LIST_HEAD(gw_list);
static DEFINE_SPINLOCK(curr_gw_lock);
static DEFINE_SPINLOCK(gw_list_lock);
-atomic_t gw_clnt_class;
static struct gw_node *curr_gateway;
void *gw_get_selected(void)
@@ -57,6 +56,8 @@
void gw_election(void)
{
+ /* FIXME: get bat_priv */
+ struct bat_priv *bat_priv = netdev_priv(soft_device);
struct gw_node *gw_node, *curr_gw_tmp = NULL;
uint8_t max_tq = 0;
uint32_t max_gw_factor = 0, tmp_gw_factor = 0;
@@ -68,7 +69,7 @@
* hear about. This check is based on the daemon's uptime which we
* don't have.
**/
- if (atomic_read(&gw_clnt_class) == 0)
+ if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
return;
if (curr_gateway)
@@ -94,7 +95,7 @@
if (gw_node->deleted)
continue;
- switch (atomic_read(&gw_clnt_class)) {
+ switch (atomic_read(&bat_priv->gw_class)) {
case 1: /* fast connection */
gw_srv_class_to_kbit(gw_node->orig_node->gw_flags,
&down, &up);
@@ -155,7 +156,7 @@
spin_unlock(&curr_gw_lock);
}
-void gw_check_election(struct orig_node *orig_node)
+void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
{
struct gw_node *curr_gateway_tmp;
uint8_t gw_tq_avg, orig_tq_avg;
@@ -191,8 +192,8 @@
* if the routing class is greater than 3 the value tells us how much
* greater the TQ value of the new gateway must be
**/
- if ((atomic_read(&gw_clnt_class) > 3) &&
- (orig_tq_avg - gw_tq_avg < atomic_read(&gw_clnt_class)))
+ if ((atomic_read(&bat_priv->gw_class) > 3) &&
+ (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_class)))
return;
bat_dbg(DBG_BATMAN,
Modified: trunk/batman-adv-kernelland/gateway_client.h
===================================================================
--- trunk/batman-adv-kernelland/gateway_client.h 2010-03-22 22:30:52 UTC (rev 1613)
+++ trunk/batman-adv-kernelland/gateway_client.h 2010-03-25 01:39:32 UTC (rev 1614)
@@ -19,12 +19,10 @@
*
*/
-extern atomic_t gw_clnt_class;
-
void gw_deselect(void);
void gw_election(void);
void *gw_get_selected(void);
-void gw_check_election(struct orig_node *orig_node);
+void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node);
void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags);
void gw_node_delete(struct orig_node *orig_node);
void gw_node_purge_deleted(void);
Modified: trunk/batman-adv-kernelland/routing.c
===================================================================
--- trunk/batman-adv-kernelland/routing.c 2010-03-22 22:30:52 UTC (rev 1613)
+++ trunk/batman-adv-kernelland/routing.c 2010-03-25 01:39:32 UTC (rev 1614)
@@ -233,6 +233,8 @@
unsigned char *hna_buff, int hna_buff_len,
char is_duplicate)
{
+ /* FIXME: get bat_priv */
+ struct bat_priv *bat_priv = netdev_priv(soft_device);
struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
int tmp_hna_buff_len;
@@ -317,8 +319,8 @@
orig_node->gw_flags = batman_packet->gw_flags;
/* restart gateway selection if fast or late switching was enabled */
- if ((orig_node->gw_flags) && (atomic_read(&gw_clnt_class) > 2))
- gw_check_election(orig_node);
+ if ((orig_node->gw_flags) && (atomic_read(&bat_priv->gw_class) > 2))
+ gw_check_election(bat_priv, orig_node);
}
static char count_real_packets(struct ethhdr *ethhdr,
11 years
r1613 - branches/batctl-0.2.x
by postmaster@open-mesh.net
Author: simon
Date: 2010-03-22 23:30:52 +0100 (Mon, 22 Mar 2010)
New Revision: 1613
Modified:
branches/batctl-0.2.x/main.h
Log:
batctl-0.2.x: Change version to 0.2.2-beta
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Modified: branches/batctl-0.2.x/main.h
===================================================================
--- branches/batctl-0.2.x/main.h 2010-03-22 21:52:26 UTC (rev 1612)
+++ branches/batctl-0.2.x/main.h 2010-03-22 22:30:52 UTC (rev 1613)
@@ -21,6 +21,6 @@
-#define SOURCE_VERSION "0.2.1" /*put exactly one distinct word inside the string like "0.3-pre-alpha" or "0.3-rc1" or "0.3" */
+#define SOURCE_VERSION "0.2.2-beta" /*put exactly one distinct word inside the string like "0.3-pre-alpha" or "0.3-rc1" or "0.3" */
#define BAT_DEVICE "/dev/batman-adv"
11 years
[git] batman-adv annotated tag, v0.2.1, created. v0.2.1
by postmaster@open-mesh.net
The annotated tag, v0.2.1 has been created
at c48b27ded4706b824259f674f97685b14e42b8eb (tag)
tagging 5c4633c532a7a9b5adfe5dbf3f5e97fff307216e (commit)
replaces v0.2
tagged by Sven Eckelmann
on Mon Mar 22 22:57:06 2010 +0100
- Shortlog ------------------------------------------------------------
batman-adv-kernelland 0.2.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iQIcBAABCgAGBQJLp+eyAAoJEF2HCgfBJntGqicP/19zszFuqvKB85zdvktzAnRf
0LpSGLX+g+PpQ4nEmf/AyGkx7rS5loKr+wUHyBpsvS0EGOA9O8MiMaz2udrXyJZl
nncC0UxrExpTxFPM6BulOrI4vYp6TiEgHflhljHkI5CF8NbALe7l/fRF+wukFYrR
gB/FJM2Q4ze4+MQfMggOMAfNsIE6M2yMLpRL8OBkYNu64ZtYuUGolegMtjT1+coP
FsbQbUOjDO3UsDxohvehgN7p9frmjUsiEFxkwbveyKf8pP86EijQLaMewK7pxDw5
x33WsxBtOnq3dZmB31fLP8waW2AK8sn4w4aONN7ElFdihYAjZ+R961r6u9dlmtt1
6rF1X8/kKlfs+AsNOq6z9ZoXLY562oQysxAJ8lXR421T/ytx7Gw2WuDy/1JyzyOK
C4rVL679pBm0iz2rr9r2Yu7Iti2C/S7NhfLqWrkqTkii15lbuWGtMFT6uHsRX4E0
+/NYpTF5rDsAbqxXkWbJO0W6baA6eok5HgPS4iQkLSKgGtGoNOC3ZFSL0ISWx7uo
8CpNAA4bj/oxXr0EeYCPzkjLEzOqNLgoaTyyHN+8J5B4ZGBGinBRSMO6SmyBFr4Q
QXS8ZFhDolUANBimOTA6V5hIAJfL59O0M4Ci3cLBrS5zKALyYX/aG1b10HbLq8xi
yXBbfzEnlE1UD9yN3zdj
=FoAU
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
--
batman-adv
11 years
r1612 - tags
by postmaster@open-mesh.net
Author: simon
Date: 2010-03-22 22:52:26 +0100 (Mon, 22 Mar 2010)
New Revision: 1612
Added:
tags/batctl-0.2.1/
Log:
tag batctl 0.2.1
11 years
r1611 - branches/batctl-0.2.x
by postmaster@open-mesh.net
Author: simon
Date: 2010-03-22 22:51:01 +0100 (Mon, 22 Mar 2010)
New Revision: 1611
Modified:
branches/batctl-0.2.x/README
Log:
batctl-0.2.x: Update README's vis section
This patch adds a short description and a more detailed explanation
of the vis_data output. Furthermore the final steps of how to
convert a vis-dot file to a png graphic is now being explained here.
Signed-off-by: Linus L?\195?\188ssing <linus.luessing(a)web.de>
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Modified: branches/batctl-0.2.x/README
===================================================================
--- branches/batctl-0.2.x/README 2010-03-21 22:05:47 UTC (rev 1610)
+++ branches/batctl-0.2.x/README 2010-03-22 21:51:01 UTC (rev 1611)
@@ -335,7 +335,7 @@
* ca:a1:5b:e5:00:00 via fe:fe:00:00:06:01
batctl vis_server
-================
+=================
display or modify the status of the VIS server
@@ -348,4 +348,81 @@
[ ] server mode (server enabled)
+batctl vis_data
+===============
+display the VIS data in dot or JSON format
+
+
+Usage:
+
+batctl vis dot {-h}{--no-HNA|-H} {--no-2nd|-2} {--numbers|-n}
+or
+batctl vis json {-h}{--no-HNA|-H} {--no-2nd|-2} {--numbers|-n}
+
+
+Example:
+(A <- 100% -> B,B-if2 <- 50% -> C)
+
+$ batctl vis_data dot
+digraph {
+ "A" -> "B" [label="1.00"]
+ "A" -> "00:ff:f3:cc:68:ac" [label="HNA"]
+ subgraph "cluster_A" {
+ "A" [peripheries=2]
+ }
+ "B" -> "A" [label="1.00"]
+ "B-if2" -> "C" [label="2.00"]
+ "B" -> "22:ff:f3:cc:68:ac" [label="HNA"]
+ subgraph "cluster_B" {
+ "B" [peripheries=2]
+ "B-if2"
+ }
+ "C" -> "B-if2" [label="2.00"]
+ "C" -> "44:ff:f3:cc:68:ac" [label="HNA"]
+ subgraph "cluster_C" {
+ "C" [peripheries=2]
+ }
+}
+
+
+Explanation:
+
+The vis dot (or json) output is adding an entry for each link between two
+originator's interfaces which are being used for internal routing in batman.
+The labels are similar/compatible to the ETX metric, 1.0 means perfect
+connection (100%), 2.0 means 50%, 3.0 means 33% and so on.
+
+A host's mac address which is currently connected to the interface of a mesh
+node (either the mesh node itself or hosts being bridged into the mesh) is
+being displayed with an "HNA"-label. (--no-hna omits this output)
+
+To still have the information about which interfaces belong to which mesh node
+a subgraph/cluster is being added. The subpgraph is being labeled with a mesh
+nodes primary interface mac (= Originator MAC). It also has an additional tag
+[peripheries=2] to make this important MAC address visible, for instance in an
+image. (--no-2nd omits this output)
+After the conversion to a png file with graphviz-tools' fdp, all interfaces of
+a node would be combined in a visual box (see below for details).
+
+
+vis-dot to png
+--------------
+
+The vis dot output could then further be converted to an image of the topology
+graph, e.g. with the help of the graphviz-tools. The according commands could
+then look like this:
+
+$ batctl vis_data dot > /tmp/graph.dot
+$ fdp -Tpng /tmp/graph.dot > graph.png
+
+Meaning of the shapes in this image file:
+* Ellipses: All BATMAN-node and host interfaces can be found in here
+ labeled with the according interface MAC-address.
+* Boxes: interfaces belonging to one BATMAN-node
+* double circled interfaces: the primary interface of a BATMAN-node
+ (which is known to other BATMAN-nodes only, except direct neighbours)
+* Ellipses with an HNA-arrow: mesh clients (this can be a BATMAN-node itself
+ with its bat0 interface or computers/devices being bridged into the mesh)
+* Arrows with numbers: the transmit quality (in the form 1/TQ) from one
+ BATMAN interface to another BATMAN interface
11 years
r1610 - trunk/batctl/man
by postmaster@open-mesh.net
Author: marek
Date: 2010-03-21 23:05:47 +0100 (Sun, 21 Mar 2010)
New Revision: 1610
Modified:
trunk/batctl/man/batctl.8
Log:
batctl: update man page
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batctl/man/batctl.8
===================================================================
--- trunk/batctl/man/batctl.8 2010-03-21 22:05:42 UTC (rev 1609)
+++ trunk/batctl/man/batctl.8 2010-03-21 22:05:47 UTC (rev 1610)
@@ -53,53 +53,78 @@
.br
.TP
.I \fBcommands:
-.IP "\fBinterface\fP|\fBif\fP [\fBnone\fP|\fIinterface\fP]"
+.IP "\fBinterface\fP|\fBif\fP [\fBnone\fP|\fBinterface\fP]"
If no parameter is given the current interface settings are displayed
otherwise the parameter(s) are added as new interfaces. Use the "none"
keyword to deactivate all interfaces.
.br
-.IP "\fBoriginators\fP|\fBo\fP [\fB\-b\fP][\fB\-n\fP]"
-Display the originator table. Once started batctl will refresh the
-displayed originator table every second. The "\-b" option causes the
-table to be displayed only once (useful for scripts). If "\-n" is
-given batctl will not replace the MAC addresses with bat\-host names
-in the output.
+.IP "\fBoriginators\fP|\fBo\fP [\fB\-b\fP][\fB\-n\fP]"
+Once started batctl will display the list of announced gateways in the network. Use the "\-w" option to let batctl refresh the list every second. If "\-n" is given batctl will not replace the MAC addresses with bat\-host names in the output.
.br
-.IP "\fBinterval\fP|\fBit\fP [\fIorig_interval\fP]"
-If no parameter is given the current originator interval setting is
-displayed otherwise the parameter is used to set the originator
-interval. The interval is in units of milliseconds.
+.IP "\fBinterval\fP|\fBit\fP [\fBorig_interval\fP]"
+If no parameter is given the current originator interval setting is displayed otherwise the parameter is used to set the originator interval. The interval is in units of milliseconds.
.br
-.IP "\fBloglevel\fP|\fBll\fP [\fIlevel\fP]"
-If no parameter is given the current log level settings are displayed
-otherwise the parameter is used to set the log level. Level 0 disables
-all logging. Level 1 enables messages related to routing / flooding /
-broadcasting. Level 2 enables messages related to route or hna added /
-changed / deleted. Level 3 enables all messages. The messages are sent
-to the kernel log. Use \fBdmesg\fP(1) to see them.
+.IP "\fBloglevel\fP|\fBll\fP [\fBlevel\fP]"
+If no parameter is given the current log level settings are displayed otherwise the parameter is used to set the log level. Level 0 disables all logging. Level 1 enables messages related to routing / flooding / broadcasting. Level 2 enables messages related to route or hna added / changed / deleted. Level 3 enables all messages. The messages are sent to the kernel log. Use \fBdmesg\fP(1) to see them. Make sure to have debugging output enabled when compiling the module otherwise the output as well as the loglevel options won't be available.
.br
-.IP "\fBlog\fP|\fBl\fP [\fIlogfile\fP][\fB\-b\fP][\fB\-n\fP]\fP"
-batctl will read the file logfile, or stdin if the logfile parameter
-is not given, applying filtering so only the B.A.T.M.A.N. Advanced
-messages are displayed. Whenever there are new log messages appended
-to the file batctl will display them. The option "\-b" causes batctl
-to exit once the end of the file has been reached. If "\-n" is given
-batctl will not replace the MAC addresses with bat\-host names in the
-output.
+.IP "\fBlog\fP|\fBl\fP [\fBlogfile\fP][\fB\-b\fP][\fB\-n\fP]\fP"
+batctl will read the file logfile, or stdin if the logfile parameter is not given, applying filtering so only the B.A.T.M.A.N. Advanced messages are displayed. Once the end of the file has been reached batctl will exit unless the option "\-w" was specified which causes batctl to continue reading the file and print log output whenever new log data has been appended to the file.
.br
-.IP "\fBtranslocal\fP|\fBtl\fP [\fB\-b\fP][\fB\-n\fP]"
-Display the local translation table. batctl will refresh the
-displayed table every second. The "\-b" option causes the table to be
-displayed only once (useful for scripts). If "\-n" is given batctl
-will not replace the MAC addresses with bat\-host names in the output.
+.IP "\fBgw_mode|gw\fP [\fBoff\fP|\fBclient\fP|\fBserver\fP] [\fBgw_class\fP]\fP"
+If no parameter is given the current gateway mode is displayed otherwise the parameter is used to set the gateway mode. The second (optional) argument specifies the gateway class. Its function depends on whether the node is a server or a client. If the node is a server this parameter is used to inform other nodes in the network about this node's internet connection bandwidth. Just enter any number (optionally followed by "kbit" or "mbit") and the batman-adv module will guess your appropriate gateway class. Use "/" to separate the down\(hy and upload rates. You can omit the upload rate and the module will assume an upload of download / 5.
+.RS 17
+default: 2000 \-> gateway class 20
+.RE
+.RS 16
+examples: 5000 \-> gateway class 49
+.RE
+.RS 25
+ 5000kbit
+ 5mbit
+ 5mbit/1024
+ 5mbit/1024kbit
+ 5mbit/1mbit
+.RE
+.RS 7
+If the node is a gateway client the parameter will decide which criterias to consider when the batman-adv module has to choose between different internet connections announced by the aforementioned servers.
+.RE
+.RS 17
+default: 20 \-> late switch (TQ 20)
+.RE
+.RS 16
+examples: 1 -> fast connection
+.RS 16
+consider the gateway's advertised throughput as well as the link quality towards the gateway
+.RE
+.RE
+.RS 25
+ 2 \-> stable connection
+.RS 7
+chooses the gateway with the best link quality and stick with it (ignore the advertised throughput)
+.RE
+ 3 \-> fast switch connection
+.RS 7
+chooses the gateway with the best link quality but switches to another gateway as soon as a better one is found
+.RE
+ XX \-> late switch connection
+.RS 7
+chooses the gateway with the best link quality but switches to another gateway as soon as a better one is found which is at least XX TQ better than the currently selected gateway (XX has to be a number between 3 and 256).
+.RE
+.RE
.br
-.IP "\fBtransglobal\fP|\fBtg\fP [\fB\-b\fP][\fB\-n\fP]"
-Display the global translation table. batctl will refresh the
-displayed table every second. The "\-b" option causes the table to be
-displayed only once (useful for scripts). If "\-n" is given batctl
-will not replace the MAC addresses with bat\-host names in the output.
+.IP "\fBgateways|gwl\fP [\fB\-w\fP][\fB\-n\fP]"
+Once started batctl will display the list of announced gateways in the network. Use the "\-w" option to let batctl refresh the list every second. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
.br
-.IP "\fBvis dot\fP [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
+.IP "\fBtranslocal\fP|\fBtl\fP [\fB\-w\fP][\fB\-n\fP]"
+Display the local translation table. batctl will refresh the displayed table every second if the "\-w" option was given. Use "\-n" to let batctl not replace the MAC addresses with bat\-host names in the output.
+.br
+.IP "\fBtransglobal\fP|\fBtg\fP [\fB\-w\fP][\fB\-n\fP]"
+Display the global translation table. batctl will refresh the displayed table every second if the "\-w" option was given. Use "\-n" to let batctl not replace the MAC addresses with bat\-host names in the output.
+.br
+.IP "\fBvis_mode|vm\fP [\fBmode\fP]\fP"
+If no parameter is given the current vis mode is displayed otherwise the parameter is used to set the vis mode.
+.br
+.IP "\fBvis_data|vd dot\fP [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
Display the visualisation data in graphviz \fBdot\fP(1) format. If
"\-\-numbers" or "\-n" is given batctl will not replace the MAC
addresses with bat-host names in the output. With "\-\-no-HNA" or
@@ -107,7 +132,7 @@
be seen. With "\-\-no-2nd" or "\-2" a dot cluster is not formed around
primary and secondary addresses from the same device.
.br
-.IP "\fBvis json\fP [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
+.IP "\fBvis_data|vd json\fP [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
Display the visualisation data in JSON format. If "\-\-numbers" or
"\-n" is given batctl will not replace the MAC addresses with bat-host
names in the output. With "\-\-no-HNA" or "\-H" the HNA entries are
@@ -115,22 +140,13 @@
"\-\-no-2nd" or "\-2" a dot cluster is not formed around primary and
secondary addresses from the same device.
.br
-.IP "\fBgw_mode|gw [off|client|server]\fP"
-If no parameter is given the current gateway mode is displayed otherwise the parameter is used to set the gateway mode.
+.IP "\fBaggregation\fP|\fBag\fP [\fB1\fP|\fB0\fP]"
+If no parameter is given the current aggregation setting is displayed. Otherwise the parameter is used to enable or disable packet aggregation.
.br
-.IP "\fBgw_srv_list|gwl\fP"
-Once started batctl will refresh the displayed gateway server list every second. Use the "\-b" option to let batctl display the list only once (useful for scripts). If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
+.IP "\fBbonding\fP|\fBb\fP [\fB1\fP|\fB0\fP]"
+If no parameter is given the current bonding mode setting is displayed. Otherwise the parameter is used to enable or disable the bonding mode.
.br
-.IP "\fBaggregation\fP|\fBag\fP [\fB1\fP|\fB0\fP]"
-If no parameter is given the current aggregation setting is displayed.
-Otherwise the parameter is used to enable or disable packet
-aggregation.
-.br
-.IP "\fBbonding\fP|\fBb\fP [\fB1\fP|\fB0\fP]"
-If no parameter is given the current bonding mode setting is displayed.
-Otherwise the parameter is used to enable or disable the bonding mode.
-.br
-.IP "\fBping\fP|\fBp\fP [\fB\-c \fP\fIcount\fP][\fB\-i \fP\fIinterval\fP][\fB\-t \fP\fItime\fP][\fB\-R\fP] \fIMAC_address\fP|\fIbat\-host_name\fP"
+.IP "\fBping\fP|\fBp\fP [\fB\-c count\fP][\fB\-i interval\fP][\fB\-t time\fP][\fB\-R\fP] \fBMAC_address\fP|\fBbat\-host_name\fP"
Layer 2 ping of a MAC address or bat\-host name. batctl will try to
find the bat\-host name if the given parameter was not a MAC
address. The "\-c" option tells batctl how man pings should be sent
@@ -140,14 +156,14 @@
for replies, both in seconds. When run with "\-R", the route taken by
the ping messages will be recorded.
.br
-.IP "\fBtraceroute\fP|\fBtr\fP [\fB\-n\fP] \fIMAC_address\fP|\fIbat\-host_name\fP"
+.IP "\fBtraceroute\fP|\fBtr\fP [\fB\-n\fP] \fBMAC_address\fP|\fBbat\-host_name\fP"
Layer 2 traceroute to a MAC address or bat\-host name. batctl will try
to find the bat\-host name if the given parameter was not a MAC
address. batctl will send 3 packets to each host and display the
response time. If "\-n" is given batctl will not replace the MAC
addresses with bat\-host names in the output.
.br
-.IP "\fBtcpdump\fP|\fBtd\fP [\fB\-p \fP\fIfilter\fP][\fB\-n\fP] \fIinterface ...\fP"
+.IP "\fBtcpdump\fP|\fBtd\fP [\fB\-p filter\fP][\fB\-n\fP] \fBinterface ...\fP"
batctl will display all packets that are seen on the given
interface(s). The "\-p" options allows the filtering of certain packet
types: 1 - batman ogm packets, 2 - batman icmp packets, 4 - unicast
@@ -157,7 +173,7 @@
packets only. If "\-n" is given batctl will not replace the MAC
addresses with bat\-host names in the output.
.br
-.IP "\fBbisect\fP [\fB\-l \fP\fIMAC\fP][\fB\-t \fP\fIMAC\fP][\fB\-r \fP\fIMAC\fP][\fB\-s \fP\fImin\fP [\fB\- \fP\fImax\fP]][\fB\-o \fP\fIMAC\fP][\fB\-n\fP] \fIlogfile1\fP [\fIlogfile2\fP ... \fIlogfileN\fP]"
+.IP "\fBbisect\fP [\fB\-l MAC\fP][\fB\-t MAC\fP][\fB\-r MAC\fP][\fB\-s min\fP [\fB\- max\fP]][\fB\-o MAC\fP][\fB\-n\fP] \fBlogfile1\fP [\fBlogfile2\fP ... \fBlogfileN\fP]"
Analyses the logfiles to build a small internal database of all sent
sequence numbers and routing table changes. This database can then be
analyzed in a number of different ways. With "\-l" the database can be
11 years
r1609 - trunk/batctl
by postmaster@open-mesh.net
Author: marek
Date: 2010-03-21 23:05:42 +0100 (Sun, 21 Mar 2010)
New Revision: 1609
Modified:
trunk/batctl/functions.c
trunk/batctl/functions.h
trunk/batctl/main.c
trunk/batctl/proc.c
trunk/batctl/proc.h
trunk/batctl/sys.c
trunk/batctl/sys.h
trunk/batctl/vis.c
Log:
batctl: adjust to new /sysfs paths
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batctl/functions.c
===================================================================
--- trunk/batctl/functions.c 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/functions.c 2010-03-21 22:05:42 UTC (rev 1609)
@@ -268,7 +268,7 @@
return res;
}
-int write_file(char *dir, char *fname, char *value)
+int write_file(char *dir, char *fname, char *arg1, char *arg2)
{
int fd = 0, res = EXIT_FAILURE;
char full_path[500];
@@ -293,7 +293,10 @@
goto out;
}
- write_len = write(fd, value, strlen(value) + 1);
+ if (arg2)
+ write_len = dprintf(fd, "%s %s", arg1, arg2);
+ else
+ write_len = write(fd, arg1, strlen(arg1) + 1);
if (write_len < 0) {
printf("Error - can't write to file '%s': %s\n", full_path, strerror(errno));
Modified: trunk/batctl/functions.h
===================================================================
--- trunk/batctl/functions.h 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/functions.h 2010-03-21 22:05:42 UTC (rev 1609)
@@ -35,7 +35,7 @@
char *get_name_by_macaddr(struct ether_addr *mac_addr, int read_opt);
char *get_name_by_macstr(char *mac_str, int read_opt);
int read_file(char *dir, char *path, int read_opt);
-int write_file(char *dir, char *path, char *value);
+int write_file(char *dir, char *fname, char *arg1, char *arg2);
int check_proc_dir(char *dir);
extern char *line_ptr;
Modified: trunk/batctl/main.c
===================================================================
--- trunk/batctl/main.c 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/main.c 2010-03-21 22:05:42 UTC (rev 1609)
@@ -47,10 +47,10 @@
printf(" \tloglevel|ll [level] \tdisplay or modify the log level\n");
printf(" \tlog|l \tread the log produced by the kernel module\n");
printf(" \tgw_mode|gw [mode] \tdisplay or modify the gateway mode\n");
- printf(" \tgw_srv_list|gwl \tdisplay the gateway server list\n");
+ printf(" \tgateways|gwl \tdisplay the gateway server list\n");
printf(" \ttranslocal|tl \tdisplay the local translation table\n");
printf(" \ttransglobal|tg \tdisplay the global translation table\n");
- printf(" \tvis_server|vs [enabled|disabled]\tdisplay or modify the status of the VIS server\n");
+ printf(" \tvis_mode|vm [mode] \tdisplay or modify the status of the VIS server\n");
printf(" \tvis_data|vd [dot|JSON] \tdisplay the VIS data in dot or JSON format\n");
printf(" \taggregation|ag [0|1] \tdisplay or modify the packet aggregation setting\n");
printf(" \tbonding|b [0|1] \tdisplay or modify the bonding mode setting\n");
@@ -125,9 +125,9 @@
ret = handle_proc_setting(argc - 1, argv + 1, PROC_ORIG_INTERVAL, orig_interval_usage);
- } else if ((strcmp(argv[1], "vis_server") == 0) || (strcmp(argv[1], "vs") == 0)) {
+ } else if ((strcmp(argv[1], "vis_mode") == 0) || (strcmp(argv[1], "vm") == 0)) {
- ret = handle_proc_setting(argc - 1, argv + 1, PROC_VIS_SERVER, vis_server_usage);
+ ret = handle_sys_setting(argc - 1, argv + 1, SYS_VIS_MODE, vis_mode_usage);
} else if ((strcmp(argv[1], "vis_data") == 0) || (strcmp(argv[1], "vd") == 0)) {
@@ -135,11 +135,11 @@
} else if ((strcmp(argv[1], "gw_mode") == 0) || (strcmp(argv[1], "gw") == 0)) {
- ret = handle_proc_setting(argc - 1, argv + 1, PROC_GW_MODE, gw_mode_usage);
+ ret = handle_sys_setting(argc - 1, argv + 1, SYS_GW_MODE, gw_mode_usage);
- } else if ((strcmp(argv[1], "gw_srv_list") == 0) || (strcmp(argv[1], "gwl") == 0)) {
+ } else if ((strcmp(argv[1], "gateways") == 0) || (strcmp(argv[1], "gwl") == 0)) {
- ret = handle_table(argc - 1, argv + 1, PROC_GW_SRV_LIST, gw_srv_list_usage);
+ ret = handle_sys_table(argc - 1, argv + 1, SYS_GATEWAYS, gateways_usage);
} else if ((strcmp(argv[1], "aggregation") == 0) || (strcmp(argv[1], "ag") == 0)) {
Modified: trunk/batctl/proc.c
===================================================================
--- trunk/batctl/proc.c 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/proc.c 2010-03-21 22:05:42 UTC (rev 1609)
@@ -57,9 +57,9 @@
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "none") == 0)
- res = write_file(PROC_ROOT_PATH, PROC_INTERFACES, "");
+ res = write_file(PROC_ROOT_PATH, PROC_INTERFACES, "", NULL);
else
- res = write_file(PROC_ROOT_PATH, PROC_INTERFACES, argv[i]);
+ res = write_file(PROC_ROOT_PATH, PROC_INTERFACES, argv[i], NULL);
if (res != EXIT_SUCCESS)
return res;
@@ -68,15 +68,6 @@
return EXIT_SUCCESS;
}
-void gw_srv_list_usage(void)
-{
- printf("Usage: batctl [options] gw_srv_list \n");
- printf("options:\n");
- printf(" \t -h print this help\n");
- printf(" \t -n don't replace mac addresses with bat-host names\n");
- printf(" \t -w watch mode - refresh the gateway server list continuously\n");
-}
-
void orig_interval_usage(void)
{
printf("Usage: batctl [options] interval \n");
@@ -84,20 +75,6 @@
printf(" \t -h print this help\n");
}
-void vis_server_usage(void)
-{
- printf("Usage: batctl [options] vis_server \n");
- printf("options:\n");
- printf(" \t -h print this help\n");
-}
-
-void gw_mode_usage(void)
-{
- printf("Usage: batctl [options] gw_mode [mode]\n");
- printf("options:\n");
- printf(" \t -h print this help\n");
-}
-
int handle_table(int argc, char **argv, char *file_path, void table_usage(void))
{
int optchar, read_opt = USE_BAT_HOSTS;
@@ -140,5 +117,5 @@
if (argc == 1)
return read_file(PROC_ROOT_PATH, file_path, SINGLE_READ);
- return write_file(PROC_ROOT_PATH, file_path, argv[1]);
+ return write_file(PROC_ROOT_PATH, file_path, argv[1], NULL);
}
Modified: trunk/batctl/proc.h
===================================================================
--- trunk/batctl/proc.h 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/proc.h 2010-03-21 22:05:42 UTC (rev 1609)
@@ -22,16 +22,9 @@
#define PROC_ROOT_PATH "/proc/net/batman-adv/"
#define PROC_INTERFACES "interfaces"
#define PROC_ORIG_INTERVAL "orig_interval"
-#define PROC_VIS_SERVER "vis_server"
-#define PROC_VIS_DATA "vis_data"
-#define PROC_GW_MODE "gateway_mode"
-#define PROC_GW_SRV_LIST "gateway_srv_list"
int interface(int argc, char **argv);
void orig_interval_usage(void);
-void vis_server_usage(void);
-void gw_mode_usage(void);
-void gw_srv_list_usage(void);
int handle_table(int argc, char **argv, char *file_path, void table_usage(void));
int handle_proc_setting(int argc, char **argv, char *file_path, void setting_usage(void));
Modified: trunk/batctl/sys.c
===================================================================
--- trunk/batctl/sys.c 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/sys.c 2010-03-21 22:05:42 UTC (rev 1609)
@@ -73,7 +73,7 @@
static void log_level_usage(void)
{
- printf("Usage: batctl [options] loglevel \n");
+ printf("Usage: batctl [options] loglevel [level]\n");
printf("options:\n");
printf(" \t -h print this help\n");
}
@@ -94,7 +94,7 @@
}
if (argc != 1) {
- res = write_file(SYS_MODULE_PATH, SYS_LOG_LEVEL, argv[1]);
+ res = write_file(SYS_MODULE_PATH, SYS_LOG_LEVEL, argv[1], NULL);
goto out;
}
@@ -146,6 +146,15 @@
printf(" \t -w watch mode - refresh the global translation table continuously\n");
}
+void gateways_usage(void)
+{
+ printf("Usage: batctl [options] gateways \n");
+ printf("options:\n");
+ printf(" \t -h print this help\n");
+ printf(" \t -n don't replace mac addresses with bat-host names\n");
+ printf(" \t -w watch mode - refresh the gateway server list continuously\n");
+}
+
int handle_sys_table(int argc, char **argv, char *file_path, void table_usage(void))
{
int optchar, read_opt = USE_BAT_HOSTS;
@@ -172,18 +181,32 @@
void aggregation_usage(void)
{
- printf("Usage: batctl [options] aggregation \n");
+ printf("Usage: batctl [options] aggregation [0|1]\n");
printf("options:\n");
printf(" \t -h print this help\n");
}
void bonding_usage(void)
{
- printf("Usage: batctl [options] bonding \n");
+ printf("Usage: batctl [options] bonding [0|1]\n");
printf("options:\n");
printf(" \t -h print this help\n");
}
+void gw_mode_usage(void)
+{
+ printf("Usage: batctl [options] gw_mode [mode]\n");
+ printf("options:\n");
+ printf(" \t -h print this help\n");
+}
+
+void vis_mode_usage(void)
+{
+ printf("Usage: batctl [options] vis_mode [mode]\n");
+ printf("options:\n");
+ printf(" \t -h print this help\n");
+}
+
int handle_sys_setting(int argc, char **argv, char *file_path, void setting_usage(void))
{
int optchar, res;
@@ -240,5 +263,5 @@
return EXIT_FAILURE;
write_file:
- return write_file(SYS_BATIF_PATH, file_path, argv[1]);
+ return write_file(SYS_BATIF_PATH, file_path, argv[1], argc > 2 ? argv[2] : NULL);
}
Modified: trunk/batctl/sys.h
===================================================================
--- trunk/batctl/sys.h 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/sys.h 2010-03-21 22:05:42 UTC (rev 1609)
@@ -29,12 +29,19 @@
#define SYS_TRANSTABLE_GLOBAL "transtable_global"
#define SYS_AGGR "aggregate_ogm"
#define SYS_BONDING "bonding"
+#define SYS_GW_MODE "gw_mode"
+#define SYS_GATEWAYS "gateways"
+#define SYS_VIS_MODE "vis_mode"
+#define SYS_VIS_DATA "vis_data"
void originators_usage(void);
void trans_local_usage(void);
void trans_global_usage(void);
void aggregation_usage(void);
void bonding_usage(void);
+void gw_mode_usage(void);
+void gateways_usage(void);
+void vis_mode_usage(void);
int log_print(int argc, char **argv);
int handle_loglevel(int argc, char **argv);
int handle_sys_table(int argc, char **argv, char *file_path, void table_usage(void));
Modified: trunk/batctl/vis.c
===================================================================
--- trunk/batctl/vis.c 2010-03-21 22:05:34 UTC (rev 1608)
+++ trunk/batctl/vis.c 2010-03-21 22:05:42 UTC (rev 1609)
@@ -29,7 +29,7 @@
#include "vis.h"
#include "functions.h"
#include "bat-hosts.h"
-#include "proc.h"
+#include "sys.h"
#define TQ_MAX_VALUE 255
@@ -168,9 +168,9 @@
if (check_proc_dir("/proc") != EXIT_SUCCESS)
return NULL;
- strncpy(full_path, PROC_ROOT_PATH, strlen(PROC_ROOT_PATH));
- full_path[strlen(PROC_ROOT_PATH)] = '\0';
- strncat(full_path, PROC_VIS_DATA,
+ strncpy(full_path, SYS_BATIF_PATH, strlen(SYS_BATIF_PATH));
+ full_path[strlen(SYS_BATIF_PATH)] = '\0';
+ strncat(full_path, SYS_VIS_DATA,
sizeof(full_path) - strlen(full_path));
return fopen(full_path, "r");
11 years
r1608 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-03-21 23:05:34 +0100 (Sun, 21 Mar 2010)
New Revision: 1608
Modified:
trunk/batman-adv-kernelland/aggregation.c
trunk/batman-adv-kernelland/aggregation.h
trunk/batman-adv-kernelland/bat_sysfs.c
trunk/batman-adv-kernelland/gateway_client.c
trunk/batman-adv-kernelland/gateway_client.h
trunk/batman-adv-kernelland/gateway_common.c
trunk/batman-adv-kernelland/gateway_common.h
trunk/batman-adv-kernelland/main.c
trunk/batman-adv-kernelland/main.h
trunk/batman-adv-kernelland/originator.c
trunk/batman-adv-kernelland/originator.h
trunk/batman-adv-kernelland/proc.c
trunk/batman-adv-kernelland/proc.h
trunk/batman-adv-kernelland/routing.c
trunk/batman-adv-kernelland/routing.h
trunk/batman-adv-kernelland/send.c
trunk/batman-adv-kernelland/soft-interface.c
trunk/batman-adv-kernelland/translation-table.c
trunk/batman-adv-kernelland/types.h
trunk/batman-adv-kernelland/vis.c
trunk/batman-adv-kernelland/vis.h
Log:
batman-adv: convert more files from /proc to /sys
converted files:
vis_mode, gw_mode, vis_data, gateways
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv-kernelland/aggregation.c
===================================================================
--- trunk/batman-adv-kernelland/aggregation.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/aggregation.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -165,10 +165,10 @@
(1 << forw_packet_aggr->num_packets);
}
-void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
+void add_bat_packet_to_list(struct bat_priv *bat_priv,
+ unsigned char *packet_buff, int packet_len,
struct batman_if *if_incoming, char own_packet,
- unsigned long send_time,
- struct bat_priv *bat_priv)
+ unsigned long send_time)
{
/**
* _aggr -> pointer to the packet we want to aggregate with
Modified: trunk/batman-adv-kernelland/aggregation.h
===================================================================
--- trunk/batman-adv-kernelland/aggregation.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/aggregation.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -30,9 +30,9 @@
(next_buff_pos <= MAX_AGGREGATION_BYTES);
}
-void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
- struct batman_if *if_outgoing, char own_packet,
- unsigned long send_time,
- struct bat_priv *bat_priv);
+void add_bat_packet_to_list(struct bat_priv *bat_priv,
+ unsigned char *packet_buff, int packet_len,
+ struct batman_if *if_incoming, char own_packet,
+ unsigned long send_time);
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
int packet_len, struct batman_if *if_incoming);
Modified: trunk/batman-adv-kernelland/bat_sysfs.c
===================================================================
--- trunk/batman-adv-kernelland/bat_sysfs.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/bat_sysfs.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -24,6 +24,9 @@
#include "translation-table.h"
#include "originator.h"
#include "hard-interface.h"
+#include "gateway_common.h"
+#include "gateway_client.h"
+#include "vis.h"
#define to_dev(obj) container_of(obj, struct device, kobj)
@@ -51,6 +54,54 @@
.write = _write, \
};
+static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr,
+ char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+ int aggr_status = atomic_read(&bat_priv->aggregation_enabled);
+
+ return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1 \n",
+ aggr_status == 0 ? "disabled" : "enabled");
+}
+
+static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ int aggr_tmp = -1;
+
+ if (((count == 2) && (buff[0] == '1')) ||
+ (strncmp(buff, "enable", 6) == 0))
+ aggr_tmp = 1;
+
+ if (((count == 2) && (buff[0] == '0')) ||
+ (strncmp(buff, "disable", 7) == 0))
+ aggr_tmp = 0;
+
+ if (aggr_tmp < 0) {
+ if (buff[count - 1] == '\n')
+ buff[count - 1] = '\0';
+
+ printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n",
+ net_dev->name, buff);
+ return -EINVAL;
+ }
+
+ if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp)
+ return count;
+
+ printk(KERN_INFO "batman-adv:Changing aggregation from: %s to: %s on mesh: %s\n",
+ atomic_read(&bat_priv->aggregation_enabled) == 1 ?
+ "enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled",
+ net_dev->name);
+
+ atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp);
+ return count;
+}
+
static ssize_t show_bond(struct kobject *kobj, struct attribute *attr,
char *buff)
{
@@ -100,61 +151,117 @@
return count;
}
-static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr,
+static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
char *buff)
{
struct device *dev = to_dev(kobj->parent);
struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
- int aggr_status = atomic_read(&bat_priv->aggregation_enabled);
+ int vis_mode = atomic_read(&bat_priv->vis_mode);
- return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1 \n",
- aggr_status == 0 ? "disabled" : "enabled");
+ return sprintf(buff, "status: %s\ncommands: client, server, %d, %d \n",
+ vis_mode == VIS_TYPE_CLIENT_UPDATE ?
+ "client" : "server",
+ VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE);
}
-static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr,
+static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
char *buff, size_t count)
{
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
struct bat_priv *bat_priv = netdev_priv(net_dev);
- int aggr_tmp = -1;
+ unsigned long val;
+ int ret, vis_mode_tmp = -1;
- if (((count == 2) && (buff[0] == '1')) ||
- (strncmp(buff, "enable", 6) == 0))
- aggr_tmp = 1;
+ ret = strict_strtoul(buff, 10, &val);
- if (((count == 2) && (buff[0] == '0')) ||
- (strncmp(buff, "disable", 7) == 0))
- aggr_tmp = 0;
+ if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) ||
+ (strncmp(buff, "client", 6) == 0))
+ vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE;
- if (aggr_tmp < 0) {
+ if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) ||
+ (strncmp(buff, "server", 6) == 0))
+ vis_mode_tmp = VIS_TYPE_SERVER_SYNC;
+
+ if (vis_mode_tmp < 0) {
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
- printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n",
+ printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n",
net_dev->name, buff);
return -EINVAL;
}
- if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp)
+ if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
return count;
- printk(KERN_INFO "batman-adv:Changing aggregation from: %s to: %s on mesh: %s\n",
- atomic_read(&bat_priv->aggregation_enabled) == 1 ?
- "enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled",
- net_dev->name);
+ printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n",
+ atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
+ "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
+ "client" : "server", net_dev->name);
- atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp);
+ atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
return count;
}
+static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
+ char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+ int down, up, bytes_written;
+ int gw_mode = atomic_read(&bat_priv->gw_mode);
+ int gw_class = atomic_read(&bat_priv->gw_class);
+
+ switch (gw_mode) {
+ case GW_MODE_CLIENT:
+ bytes_written = sprintf(buff, "status: %s (gw_class: %i)\n",
+ GW_MODE_CLIENT_NAME, gw_class);
+ break;
+ case GW_MODE_SERVER:
+ gw_srv_class_to_kbit(gw_class, &down, &up);
+ bytes_written = sprintf(buff,
+ "status: %s (gw_class: %i -> propagating: %i%s/%i%s)\n",
+ GW_MODE_SERVER_NAME, gw_class,
+ (down > 2048 ? down / 1024 : down),
+ (down > 2048 ? "MBit" : "KBit"),
+ (up > 2048 ? up / 1024 : up),
+ (up > 2048 ? "MBit" : "KBit"));
+ break;
+ default:
+ bytes_written = sprintf(buff, "status: %s\n",
+ GW_MODE_OFF_NAME);
+ break;
+ }
+
+ bytes_written += sprintf(buff + bytes_written,
+ "commands: %s, %s <opt arg>, %s <opt arg> \n",
+ GW_MODE_OFF_NAME, GW_MODE_CLIENT_NAME,
+ GW_MODE_SERVER_NAME);
+ return bytes_written;
+}
+
+static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+
+ return gw_mode_set(bat_priv, buff, count);
+}
+
static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR,
show_aggr_ogm, store_aggr_ogm);
static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond);
+static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
+static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
static struct bat_attribute *mesh_attrs[] = {
+ &bat_attr_aggregate_ogm,
&bat_attr_bonding,
- &bat_attr_aggregate_ogm,
+ &bat_attr_vis_mode,
+ &bat_attr_gw_mode,
NULL,
};
@@ -165,19 +272,6 @@
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
- rcu_read_lock();
- if (list_empty(&if_list)) {
- rcu_read_unlock();
-
- if (off == 0)
- return sprintf(buff,
- "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
- net_dev->name);
-
- return 0;
- }
- rcu_read_unlock();
-
return hna_local_fill_buffer_text(net_dev, buff, count, off);
}
@@ -188,19 +282,6 @@
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
- rcu_read_lock();
- if (list_empty(&if_list)) {
- rcu_read_unlock();
-
- if (off == 0)
- return sprintf(buff,
- "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
- net_dev->name);
-
- return 0;
- }
- rcu_read_unlock();
-
return hna_global_fill_buffer_text(net_dev, buff, count, off);
}
@@ -208,45 +289,44 @@
struct bin_attribute *bin_attr,
char *buff, loff_t off, size_t count)
{
- /* FIXME: orig table should exist per batif */
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
- rcu_read_lock();
- if (list_empty(&if_list)) {
- rcu_read_unlock();
+ return orig_fill_buffer_text(net_dev, buff, count, off);
+}
- if (off == 0)
- return sprintf(buff,
- "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
- net_dev->name);
+static ssize_t gateways_read(struct kobject *kobj,
+ struct bin_attribute *bin_attr,
+ char *buff, loff_t off, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
- return 0;
- }
+ return gw_client_fill_buffer_text(net_dev, buff, count, off);
+}
- if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
- rcu_read_unlock();
+static ssize_t vis_data_read(struct kobject *kobj,
+ struct bin_attribute *bin_attr,
+ char *buff, loff_t off, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
- if (off == 0)
- return sprintf(buff,
- "BATMAN mesh %s disabled - primary interface not active\n",
- net_dev->name);
-
- return 0;
- }
- rcu_read_unlock();
-
- return orig_fill_buffer_text(buff, count, off);
+ return vis_fill_buffer_text(net_dev, buff, count, off);
}
static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL);
static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL);
static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL);
+static BAT_BIN_ATTR(gateways, S_IRUGO, gateways_read, NULL);
+static BAT_BIN_ATTR(vis_data, S_IRUGO, vis_data_read, NULL);
static struct bin_attribute *mesh_bin_attrs[] = {
&bat_attr_transtable_local,
&bat_attr_transtable_global,
&bat_attr_originators,
+ &bat_attr_gateways,
+ &bat_attr_vis_data,
NULL,
};
@@ -262,6 +342,9 @@
routine as soon as we have it */
atomic_set(&bat_priv->aggregation_enabled, 1);
atomic_set(&bat_priv->bonding_enabled, 0);
+ atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE);
+ atomic_set(&bat_priv->gw_mode, GW_MODE_OFF);
+ atomic_set(&bat_priv->gw_class, 0);
bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
batif_kobject);
Modified: trunk/batman-adv-kernelland/gateway_client.c
===================================================================
--- trunk/batman-adv-kernelland/gateway_client.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/gateway_client.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -22,6 +22,7 @@
#include "main.h"
#include "gateway_client.h"
#include "gateway_common.h"
+#include "hard-interface.h"
#include "compat.h"
#include <linux/ip.h>
#include <linux/udp.h>
@@ -333,12 +334,49 @@
(up > 2048 ? "MBit" : "KBit"));
}
-int gw_client_fill_buffer_text(unsigned char *buff, int buff_len)
+int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
+ size_t count, loff_t off)
{
struct gw_node *gw_node;
+ size_t hdr_len, tmp_len;
int bytes_written = 0, gw_count = 0;
rcu_read_lock();
+ if (list_empty(&if_list)) {
+ rcu_read_unlock();
+
+ if (off == 0)
+ return sprintf(buff,
+ "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+ net_dev->name);
+
+ return 0;
+ }
+
+ if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
+ rcu_read_unlock();
+
+ if (off == 0)
+ return sprintf(buff,
+ "BATMAN mesh %s disabled - primary interface not active\n",
+ net_dev->name);
+
+ return 0;
+ }
+
+ hdr_len = sprintf(buff,
+ " %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n",
+ "Gateway", "#", TQ_MAX_VALUE, "Nexthop",
+ "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR,
+ ((struct batman_if *)if_list.next)->dev,
+ ((struct batman_if *)if_list.next)->addr_str,
+ net_dev->name);
+ rcu_read_unlock();
+
+ if (off < hdr_len)
+ bytes_written = hdr_len;
+
+ rcu_read_lock();
list_for_each_entry_rcu(gw_node, &gw_list, list) {
if (gw_node->deleted)
continue;
@@ -346,29 +384,35 @@
if (!gw_node->orig_node->router)
continue;
- if (buff_len < bytes_written + (2 * ETH_STR_LEN) + 30)
+ if (count < bytes_written + (2 * ETH_STR_LEN) + 30)
break;
- bytes_written += _write_buffer_text(buff,
- bytes_written,
- gw_node);
+ tmp_len = _write_buffer_text(buff, bytes_written, gw_node);
gw_count++;
+
+ hdr_len += tmp_len;
+
+ if (off >= hdr_len)
+ continue;
+
+ bytes_written += tmp_len;
}
rcu_read_unlock();
- if (gw_count == 0)
- sprintf(buff, "No gateways in range ... \n");
+ if ((gw_count == 0) && (off == 0))
+ bytes_written += sprintf(buff + bytes_written,
+ "No gateways in range ... \n");
return bytes_written;
}
-bool gw_is_target(struct sk_buff *skb)
+bool gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
{
struct ethhdr *ethhdr;
struct iphdr *iphdr;
struct udphdr *udphdr;
- if (atomic_read(&gw_mode) != GW_MODE_CLIENT)
+ if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
return false;
if (!curr_gateway)
Modified: trunk/batman-adv-kernelland/gateway_client.h
===================================================================
--- trunk/batman-adv-kernelland/gateway_client.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/gateway_client.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -29,5 +29,6 @@
void gw_node_delete(struct orig_node *orig_node);
void gw_node_purge_deleted(void);
void gw_node_list_free(void);
-int gw_client_fill_buffer_text(unsigned char *buff, int buff_len);
-bool gw_is_target(struct sk_buff *skb);
+int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
+ size_t count, loff_t off);
+bool gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb);
Modified: trunk/batman-adv-kernelland/gateway_common.c
===================================================================
--- trunk/batman-adv-kernelland/gateway_common.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/gateway_common.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -24,9 +24,6 @@
#include "gateway_client.h"
#include "compat.h"
-atomic_t gw_mode;
-atomic_t gw_srv_class;
-
/* calculates the gateway class from kbit */
static void kbit_to_gw_srv_class(int down, int up, long *gw_srv_class)
{
@@ -80,24 +77,24 @@
}
static bool parse_gw_mode_tok(char *tokptr, long *gw_mode_tmp,
- char **gw_mode_tmp_str, long *gw_clnt_class_tmp,
+ char **gw_mode_tmp_str, long *gw_class_tmp,
long *up, long *down)
{
- int ret;
+ int ret, multi;
char *slash_ptr, *tmp_ptr;
switch (*gw_mode_tmp) {
case GW_MODE_CLIENT:
- ret = strict_strtoul(tokptr, 10, gw_clnt_class_tmp);
+ ret = strict_strtoul(tokptr, 10, gw_class_tmp);
if (ret) {
- printk(KERN_ERR "Client class of gateway mode invalid: %s\n",
+ printk(KERN_ERR "batman-adv: Client class of gateway mode invalid: %s\n",
tokptr);
return false;
}
- if (*gw_clnt_class_tmp > TQ_MAX_VALUE) {
- printk(KERN_ERR "Client class of gateway mode greater than %i: %ld\n",
- TQ_MAX_VALUE, *gw_clnt_class_tmp);
+ if (*gw_class_tmp > TQ_MAX_VALUE) {
+ printk(KERN_ERR "batman-adv: Client class of gateway mode greater than %i: %ld\n",
+ TQ_MAX_VALUE, *gw_class_tmp);
return false;
}
@@ -107,39 +104,51 @@
if (slash_ptr)
*slash_ptr = 0;
+ multi = 1;
+
+ if (strlen(tokptr) > 4) {
+ tmp_ptr = tokptr + strlen(tokptr) - 4;
+
+ if (strnicmp(tmp_ptr, "mbit", 4) == 0)
+ multi = 1024;
+
+ if ((strnicmp(tmp_ptr, "kbit", 4) == 0) ||
+ (multi > 1))
+ *tmp_ptr = '\0';
+ }
+
ret = strict_strtoul(tokptr, 10, down);
if (ret) {
- printk(KERN_ERR "Download speed of gateway mode invalid: %s\n",
+ printk(KERN_ERR "batman-adv: Download speed of gateway mode invalid: %s\n",
tokptr);
return false;
}
- tmp_ptr = tokptr + strlen(tokptr) - 4;
+ *down *= multi;
- if ((strlen(tokptr) > 4) &&
- ((strncmp(tmp_ptr, "MBit", 4) == 0) ||
- (strncmp(tmp_ptr, "mbit", 4) == 0) ||
- (strncmp(tmp_ptr, "Mbit", 4) == 0)))
- *down *= 1024;
-
/* we also got some upload info */
if (slash_ptr) {
+ multi = 1;
+
+ if (strlen(slash_ptr + 1) > 4) {
+ tmp_ptr = slash_ptr + 1 + strlen(slash_ptr + 1) - 4;
+
+ if (strnicmp(tmp_ptr, "mbit", 4) == 0)
+ multi = 1024;
+
+ if ((strnicmp(tmp_ptr, "kbit", 4) == 0) ||
+ (multi > 1))
+ *tmp_ptr = '\0';
+ }
+
ret = strict_strtoul(slash_ptr + 1, 10, up);
if (ret) {
- printk(KERN_ERR "Upload speed of gateway mode invalid: %s\n",
+ printk(KERN_ERR "batman-adv: Upload speed of gateway mode invalid: %s\n",
slash_ptr + 1);
return false;
}
- tmp_ptr = slash_ptr + 1 + strlen(slash_ptr + 1) - 4;
-
- if ((strlen(slash_ptr + 1) > 4) &&
- ((strncmp(tmp_ptr, "MBit", 4) == 0) ||
- (strncmp(tmp_ptr, "mbit", 4) == 0) ||
- (strncmp(tmp_ptr, "Mbit", 4) == 0)))
- *up *= 1024;
-
- *slash_ptr = '/';
+ *up *= multi;
}
break;
@@ -163,27 +172,18 @@
return true;
}
-ssize_t gw_mode_set(const char __user *userbuffer, size_t count)
+ssize_t gw_mode_set(struct bat_priv *bat_priv, char *buff, size_t count)
{
- char *gw_mode_string, *tokptr, *cp;
+ char *tokptr, *cp, finished;
char *gw_mode_curr_str, *gw_mode_tmp_str = NULL;
- int finished, not_copied = 0;
long gw_mode_curr, gw_mode_tmp = GW_MODE_OFF;
- long gw_srv_class_tmp = 0, gw_clnt_class_tmp = 0, up = 0, down = 0;
+ long gw_class_tmp = 0, up = 0, down = 0;
bool ret;
- gw_mode_string = kmalloc(count, GFP_KERNEL);
+ tokptr = buff;
+ gw_mode_curr = atomic_read(&bat_priv->gw_mode);
- if (!gw_mode_string)
- return -ENOMEM;
-
- not_copied = copy_from_user(gw_mode_string, userbuffer, count);
- gw_mode_string[count - not_copied - 1] = 0;
-
- tokptr = gw_mode_string;
- gw_mode_curr = atomic_read(&gw_mode);
-
- for (cp = gw_mode_string, finished = 0; !finished; cp++) {
+ for (cp = buff, finished = 0; !finished; cp++) {
switch (*cp) {
case 0:
finished = 1;
@@ -191,14 +191,19 @@
case '\n':
case '\t':
*cp = 0;
+
+ if (strlen(tokptr) == 0)
+ goto next;
+
ret = parse_gw_mode_tok(tokptr, &gw_mode_tmp,
&gw_mode_tmp_str,
- &gw_clnt_class_tmp,
+ &gw_class_tmp,
&up, &down);
if (!ret)
goto end;
+next:
tokptr = cp + 1;
break;
default:
@@ -207,9 +212,9 @@
}
if (!gw_mode_tmp_str) {
- printk(KERN_INFO "Gateway mode can only be set to: '%s', '%s' or '%s' - given value: %s\n",
+ printk(KERN_INFO "batman-adv: Gateway mode can only be set to: '%s', '%s' or '%s' - given value: %s\n",
GW_MODE_OFF_NAME, GW_MODE_CLIENT_NAME,
- GW_MODE_SERVER_NAME, gw_mode_string);
+ GW_MODE_SERVER_NAME, buff);
goto end;
}
@@ -227,12 +232,11 @@
switch (gw_mode_tmp) {
case GW_MODE_CLIENT:
- if ((gw_mode_tmp == GW_MODE_CLIENT) && (!gw_clnt_class_tmp))
- gw_clnt_class_tmp = 20;
+ if ((gw_mode_tmp == GW_MODE_CLIENT) && (!gw_class_tmp))
+ gw_class_tmp = 20;
- printk(KERN_INFO "Changing gateway mode from: '%s' to: '%s' (gw_clnt_class: %ld)\n",
- gw_mode_curr_str, gw_mode_tmp_str,
- gw_clnt_class_tmp);
+ printk(KERN_INFO "batman-adv: Changing gateway mode from: '%s' to: '%s' (gw_class: %ld)\n",
+ gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp);
break;
case GW_MODE_SERVER:
if (!down)
@@ -241,39 +245,36 @@
if (!up)
up = down / 5;
- kbit_to_gw_srv_class(down, up, &gw_srv_class_tmp);
+ kbit_to_gw_srv_class(down, up, &gw_class_tmp);
/**
* the gw class we guessed above might not match the given
* speeds, hence we need to calculate it back to show the
* number that is going to be propagated
**/
- gw_srv_class_to_kbit((uint8_t)gw_srv_class_tmp,
+ gw_srv_class_to_kbit((uint8_t)gw_class_tmp,
(int *)&down, (int *)&up);
printk(KERN_INFO
- "Changing gateway mode from: '%s' to: '%s' (gw_srv_class: %ld -> propagating: %ld%s/%ld%s)\n",
- gw_mode_curr_str, gw_mode_tmp_str,
- gw_srv_class_tmp,
+ "batman-adv: Changing gateway mode from: '%s' to: '%s' (gw_class: %ld -> propagating: %ld%s/%ld%s)\n",
+ gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp,
(down > 2048 ? down / 1024 : down),
(down > 2048 ? "MBit" : "KBit"),
(up > 2048 ? up / 1024 : up),
(up > 2048 ? "MBit" : "KBit"));
break;
default:
- printk(KERN_INFO "Changing gateway mode from: '%s' to: '%s'\n",
+ printk(KERN_INFO "batman-adv: Changing gateway mode from: '%s' to: '%s'\n",
gw_mode_curr_str, gw_mode_tmp_str);
break;
}
- atomic_set(&gw_mode, gw_mode_tmp);
- atomic_set(&gw_srv_class, gw_srv_class_tmp);
- atomic_set(&gw_clnt_class, gw_clnt_class_tmp);
+ atomic_set(&bat_priv->gw_mode, gw_mode_tmp);
+ atomic_set(&bat_priv->gw_class, gw_class_tmp);
- if (gw_clnt_class_tmp == 0)
+ if (gw_class_tmp == 0)
gw_deselect();
end:
- kfree(gw_mode_string);
return count;
}
Modified: trunk/batman-adv-kernelland/gateway_common.h
===================================================================
--- trunk/batman-adv-kernelland/gateway_common.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/gateway_common.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -29,8 +29,5 @@
#define GW_MODE_CLIENT_NAME "client"
#define GW_MODE_SERVER_NAME "server"
-extern atomic_t gw_mode;
-extern atomic_t gw_srv_class;
-
void gw_srv_class_to_kbit(uint8_t gw_class, int *down, int *up);
-ssize_t gw_mode_set(const char __user *userbuffer, size_t count);
+ssize_t gw_mode_set(struct bat_priv *bat_priv, char *buff, size_t count);
Modified: trunk/batman-adv-kernelland/main.c
===================================================================
--- trunk/batman-adv-kernelland/main.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/main.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -29,7 +29,6 @@
#include "device.h"
#include "translation-table.h"
#include "hard-interface.h"
-#include "gateway_common.h"
#include "gateway_client.h"
#include "types.h"
#include "vis.h"
@@ -47,7 +46,6 @@
atomic_t originator_interval;
atomic_t vis_interval;
-atomic_t vis_mode;
int16_t num_hna;
int16_t num_ifs;
@@ -87,10 +85,6 @@
atomic_set(&originator_interval, 1000);
atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
* for debugging now. */
- atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE);
- atomic_set(&gw_mode, GW_MODE_OFF);
- atomic_set(&gw_srv_class, 0);
- atomic_set(&gw_clnt_class, 0);
/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
Modified: trunk/batman-adv-kernelland/main.h
===================================================================
--- trunk/batman-adv-kernelland/main.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/main.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -133,8 +133,6 @@
extern atomic_t originator_interval;
extern atomic_t vis_interval;
-extern atomic_t vis_mode;
-extern atomic_t bonding_enabled;
extern int16_t num_hna;
extern int16_t num_ifs;
Modified: trunk/batman-adv-kernelland/originator.c
===================================================================
--- trunk/batman-adv-kernelland/originator.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/originator.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -28,6 +28,7 @@
#include "routing.h"
#include "compat.h"
#include "gateway_client.h"
+#include "hard-interface.h"
static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
@@ -207,7 +208,6 @@
return neigh_purged;
}
-
static bool purge_orig_node(struct orig_node *orig_node)
{
/* FIXME: each batman_if will be attached to a softif */
@@ -229,7 +229,7 @@
orig_node->hna_buff_len);
/* update bonding candidates, we could have lost
* some candidates. */
- update_bonding_candidates(orig_node, bat_priv);
+ update_bonding_candidates(bat_priv, orig_node);
}
}
return false;
@@ -261,7 +261,8 @@
start_purge_timer();
}
-ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off)
+ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
+ size_t count, loff_t off)
{
HASHIT(hashit);
struct orig_node *orig_node;
@@ -272,12 +273,35 @@
char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN];
rcu_read_lock();
+ if (list_empty(&if_list)) {
+ rcu_read_unlock();
+
+ if (off == 0)
+ return sprintf(buff,
+ "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+ net_dev->name);
+
+ return 0;
+ }
+
+ if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
+ rcu_read_unlock();
+
+ if (off == 0)
+ return sprintf(buff,
+ "BATMAN mesh %s disabled - primary interface not active\n",
+ net_dev->name);
+
+ return 0;
+ }
+
hdr_len = sprintf(buff,
- " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n",
+ " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n",
"Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
"Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
((struct batman_if *)if_list.next)->dev,
- ((struct batman_if *)if_list.next)->addr_str);
+ ((struct batman_if *)if_list.next)->addr_str,
+ net_dev->name);
rcu_read_unlock();
if (off < hdr_len)
Modified: trunk/batman-adv-kernelland/originator.h
===================================================================
--- trunk/batman-adv-kernelland/originator.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/originator.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -28,4 +28,5 @@
struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming);
-ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off);
+ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
+ size_t count, loff_t off);
Modified: trunk/batman-adv-kernelland/proc.c
===================================================================
--- trunk/batman-adv-kernelland/proc.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/proc.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -33,8 +33,6 @@
static struct proc_dir_entry *proc_batman_dir, *proc_interface_file;
static struct proc_dir_entry *proc_orig_interval_file;
-static struct proc_dir_entry *proc_vis_srv_file, *proc_vis_data_file;
-static struct proc_dir_entry *proc_gw_mode_file, *proc_gw_srv_list_file;
static int proc_interfaces_read(struct seq_file *seq, void *offset)
{
@@ -177,255 +175,6 @@
return single_open(file, proc_orig_interval_read, NULL);
}
-/* setting the mode of the vis server by the user */
-static ssize_t proc_vis_srv_write(struct file *file, const char __user * buffer,
- size_t count, loff_t *ppos)
-{
- char *vis_mode_string;
- int not_copied = 0;
-
- vis_mode_string = kmalloc(count, GFP_KERNEL);
-
- if (!vis_mode_string)
- return -ENOMEM;
-
- not_copied = copy_from_user(vis_mode_string, buffer, count);
- vis_mode_string[count - not_copied - 1] = 0;
-
- if ((strcmp(vis_mode_string, "client") == 0) ||
- (strcmp(vis_mode_string, "disabled") == 0)) {
- printk(KERN_INFO "batman-adv:Setting VIS mode to client (disabling vis server)\n");
- atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE);
- } else if ((strcmp(vis_mode_string, "server") == 0) ||
- (strcmp(vis_mode_string, "enabled") == 0)) {
- printk(KERN_INFO "batman-adv:Setting VIS mode to server (enabling vis server)\n");
- atomic_set(&vis_mode, VIS_TYPE_SERVER_SYNC);
- } else
- printk(KERN_ERR "batman-adv:Unknown VIS mode: %s\n",
- vis_mode_string);
-
- kfree(vis_mode_string);
- return count;
-}
-
-static int proc_vis_srv_read(struct seq_file *seq, void *offset)
-{
- int vis_server = atomic_read(&vis_mode);
-
- seq_printf(seq, "[%c] client mode (server disabled) \n",
- (vis_server == VIS_TYPE_CLIENT_UPDATE) ? 'x' : ' ');
- seq_printf(seq, "[%c] server mode (server enabled) \n",
- (vis_server == VIS_TYPE_SERVER_SYNC) ? 'x' : ' ');
-
- return 0;
-}
-
-static int proc_vis_srv_open(struct inode *inode, struct file *file)
-{
- return single_open(file, proc_vis_srv_read, NULL);
-}
-
-static int proc_vis_data_read(struct seq_file *seq, void *offset)
-{
- HASHIT(hashit);
- struct vis_info *info;
- struct vis_info_entry *entries;
- HLIST_HEAD(vis_if_list);
- struct if_list_entry *entry;
- struct hlist_node *pos, *n;
- int i;
- char tmp_addr_str[ETH_STR_LEN];
- unsigned long flags;
- int vis_server = atomic_read(&vis_mode);
-
- rcu_read_lock();
- if (list_empty(&if_list) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) {
- rcu_read_unlock();
- goto end;
- }
-
- rcu_read_unlock();
-
- spin_lock_irqsave(&vis_hash_lock, flags);
- while (hash_iterate(vis_hash, &hashit)) {
- info = hashit.bucket->data;
- entries = (struct vis_info_entry *)
- ((char *)info + sizeof(struct vis_info));
-
- for (i = 0; i < info->packet.entries; i++) {
- if (entries[i].quality == 0)
- continue;
- proc_vis_insert_interface(entries[i].src, &vis_if_list,
- compare_orig(entries[i].src,
- info->packet.vis_orig));
- }
-
- hlist_for_each_entry(entry, pos, &vis_if_list, list) {
- addr_to_string(tmp_addr_str, entry->addr);
- seq_printf(seq, "%s,", tmp_addr_str);
-
- for (i = 0; i < info->packet.entries; i++)
- proc_vis_read_entry(seq, &entries[i],
- entry->addr, entry->primary);
-
- /* add primary/secondary records */
- if (compare_orig(entry->addr, info->packet.vis_orig))
- proc_vis_read_prim_sec(seq, &vis_if_list);
-
- seq_printf(seq, "\n");
- }
-
- hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) {
- hlist_del(&entry->list);
- kfree(entry);
- }
- }
- spin_unlock_irqrestore(&vis_hash_lock, flags);
-
-end:
- return 0;
-}
-
-static int proc_vis_data_open(struct inode *inode, struct file *file)
-{
- return single_open(file, proc_vis_data_read, NULL);
-}
-
-static int proc_gw_mode_read(struct seq_file *seq, void *offset)
-{
- int down, up;
- long gw_mode_curr = atomic_read(&gw_mode);
- uint8_t gw_srv_class_curr = (uint8_t)atomic_read(&gw_srv_class);
-
- gw_srv_class_to_kbit(gw_srv_class_curr, &down, &up);
-
- seq_printf(seq, "[%c] %s\n",
- (gw_mode_curr == GW_MODE_OFF) ? 'x' : ' ',
- GW_MODE_OFF_NAME);
-
- if (gw_mode_curr == GW_MODE_CLIENT)
- seq_printf(seq, "[x] %s (gw_clnt_class: %i)\n",
- GW_MODE_CLIENT_NAME,
- atomic_read(&gw_clnt_class));
- else
- seq_printf(seq, "[ ] %s\n", GW_MODE_CLIENT_NAME);
-
- if (gw_mode_curr == GW_MODE_SERVER)
- seq_printf(seq,
- "[x] %s (gw_srv_class: %i -> propagating: %i%s/%i%s)\n",
- GW_MODE_SERVER_NAME,
- gw_srv_class_curr,
- (down > 2048 ? down / 1024 : down),
- (down > 2048 ? "MBit" : "KBit"),
- (up > 2048 ? up / 1024 : up),
- (up > 2048 ? "MBit" : "KBit"));
- else
- seq_printf(seq, "[ ] %s\n", GW_MODE_SERVER_NAME);
-
- return 0;
-}
-
-static int proc_gw_mode_open(struct inode *inode, struct file *file)
-{
- return single_open(file, proc_gw_mode_read, NULL);
-}
-
-static ssize_t proc_gw_mode_write(struct file *instance,
- const char __user *userbuffer,
- size_t count, loff_t *data)
-{
- return gw_mode_set(userbuffer, count);
-}
-
-static int proc_gw_srv_list_read(struct seq_file *seq, void *offset)
-{
- char *buff;
- int buffsize = 4096;
-
- buff = kmalloc(buffsize, GFP_KERNEL);
- if (!buff)
- return 0;
-
- rcu_read_lock();
- if (list_empty(&if_list)) {
- rcu_read_unlock();
- seq_printf(seq,
- "BATMAN disabled - please specify interfaces to enable it\n");
- goto end;
- }
-
- if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
- rcu_read_unlock();
- seq_printf(seq,
- "BATMAN disabled - primary interface not active\n");
- goto end;
- }
-
- seq_printf(seq,
- " %-12s (%s/%i) %17s [%10s]: gw_srv_class ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n",
- "Gateway", "#", TQ_MAX_VALUE, "Nexthop",
- "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR,
- ((struct batman_if *)if_list.next)->dev,
- ((struct batman_if *)if_list.next)->addr_str);
-
- rcu_read_unlock();
-
- gw_client_fill_buffer_text(buff, buffsize);
- seq_printf(seq, "%s", buff);
-
-end:
- kfree(buff);
- return 0;
-}
-
-static int proc_gw_srv_list_open(struct inode *inode, struct file *file)
-{
- return single_open(file, proc_gw_srv_list_read, NULL);
-}
-
-/* satisfying different prototypes ... */
-static ssize_t proc_dummy_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
- return count;
-}
-
-static const struct file_operations proc_gw_srv_list_fops = {
- .owner = THIS_MODULE,
- .open = proc_gw_srv_list_open,
- .read = seq_read,
- .write = proc_dummy_write,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations proc_gw_mode_fops = {
- .owner = THIS_MODULE,
- .open = proc_gw_mode_open,
- .read = seq_read,
- .write = proc_gw_mode_write,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations proc_vis_srv_fops = {
- .owner = THIS_MODULE,
- .open = proc_vis_srv_open,
- .read = seq_read,
- .write = proc_vis_srv_write,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations proc_vis_data_fops = {
- .owner = THIS_MODULE,
- .open = proc_vis_data_open,
- .read = seq_read,
- .write = proc_dummy_write,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
static const struct file_operations proc_interfaces_fops = {
.owner = THIS_MODULE,
.open = proc_interfaces_open,
@@ -452,18 +201,6 @@
if (proc_interface_file)
remove_proc_entry(PROC_FILE_INTERFACES, proc_batman_dir);
- if (proc_vis_data_file)
- remove_proc_entry(PROC_FILE_VIS_DATA, proc_batman_dir);
-
- if (proc_vis_srv_file)
- remove_proc_entry(PROC_FILE_VIS_SRV, proc_batman_dir);
-
- if (proc_gw_mode_file)
- remove_proc_entry(PROC_FILE_GW_MODE, proc_batman_dir);
-
- if (proc_gw_srv_list_file)
- remove_proc_entry(PROC_FILE_GW_SRV_LIST, proc_batman_dir);
-
if (proc_batman_dir)
#ifdef __NET_NET_NAMESPACE_H
remove_proc_entry(PROC_ROOT_DIR, init_net.proc_net);
@@ -507,50 +244,5 @@
return -EFAULT;
}
- proc_vis_srv_file = create_proc_entry(PROC_FILE_VIS_SRV,
- S_IWUSR | S_IRUGO,
- proc_batman_dir);
- if (proc_vis_srv_file) {
- proc_vis_srv_file->proc_fops = &proc_vis_srv_fops;
- } else {
- printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_SRV);
- cleanup_procfs();
- return -EFAULT;
- }
-
- proc_vis_data_file = create_proc_entry(PROC_FILE_VIS_DATA, S_IRUGO,
- proc_batman_dir);
- if (proc_vis_data_file) {
- proc_vis_data_file->proc_fops = &proc_vis_data_fops;
- } else {
- printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_DATA);
- cleanup_procfs();
- return -EFAULT;
- }
-
- proc_gw_mode_file = create_proc_entry(PROC_FILE_GW_MODE,
- S_IWUSR | S_IRUGO,
- proc_batman_dir);
- if (proc_gw_mode_file) {
- proc_gw_mode_file->proc_fops = &proc_gw_mode_fops;
- } else {
- printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n",
- PROC_ROOT_DIR, PROC_FILE_GW_MODE);
- cleanup_procfs();
- return -EFAULT;
- }
-
- proc_gw_srv_list_file = create_proc_entry(PROC_FILE_GW_SRV_LIST,
- S_IWUSR | S_IRUGO,
- proc_batman_dir);
- if (proc_gw_srv_list_file) {
- proc_gw_srv_list_file->proc_fops = &proc_gw_srv_list_fops;
- } else {
- printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n",
- PROC_ROOT_DIR, PROC_FILE_GW_SRV_LIST);
- cleanup_procfs();
- return -EFAULT;
- }
-
return 0;
}
Modified: trunk/batman-adv-kernelland/proc.h
===================================================================
--- trunk/batman-adv-kernelland/proc.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/proc.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -25,13 +25,6 @@
#define PROC_ROOT_DIR "batman-adv"
#define PROC_FILE_INTERFACES "interfaces"
#define PROC_FILE_ORIG_INTERVAL "orig_interval"
-#define PROC_FILE_GATEWAYS "gateways"
-#define PROC_FILE_LOG "log"
-#define PROC_FILE_LOG_LEVEL "log_level"
-#define PROC_FILE_VIS_SRV "vis_server"
-#define PROC_FILE_VIS_DATA "vis_data"
-#define PROC_FILE_GW_MODE "gateway_mode"
-#define PROC_FILE_GW_SRV_LIST "gateway_srv_list"
void cleanup_procfs(void);
int setup_procfs(void);
Modified: trunk/batman-adv-kernelland/routing.c
===================================================================
--- trunk/batman-adv-kernelland/routing.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/routing.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -362,10 +362,10 @@
}
/* copy primary address for bonding */
-static void mark_bonding_address(struct orig_node *orig_node,
+static void mark_bonding_address(struct bat_priv *bat_priv,
+ struct orig_node *orig_node,
struct orig_node *orig_neigh_node,
- struct batman_packet *batman_packet,
- struct bat_priv *bat_priv)
+ struct batman_packet *batman_packet)
{
/* don't care if bonding is not enabled */
@@ -382,8 +382,8 @@
}
/* mark possible bonding candidates in the neighbor list */
-void update_bonding_candidates(struct orig_node *orig_node,
- struct bat_priv *bat_priv)
+void update_bonding_candidates(struct bat_priv *bat_priv,
+ struct orig_node *orig_node)
{
int candidates;
int interference_candidate;
@@ -642,9 +642,9 @@
update_orig(orig_node, ethhdr, batman_packet,
if_incoming, hna_buff, hna_buff_len, is_duplicate);
- mark_bonding_address(orig_node, orig_neigh_node,
- batman_packet, bat_priv);
- update_bonding_candidates(orig_node, bat_priv);
+ mark_bonding_address(bat_priv, orig_node,
+ orig_neigh_node, batman_packet);
+ update_bonding_candidates(bat_priv, orig_node);
/* is single hop (direct) neighbor */
if (is_single_hop_neigh) {
@@ -1150,6 +1150,7 @@
{
struct vis_packet *vis_packet;
struct ethhdr *ethhdr;
+ struct bat_priv *bat_priv;
int hdr_size = sizeof(struct vis_packet);
if (skb_headlen(skb) < hdr_size)
@@ -1169,15 +1170,20 @@
if (is_my_mac(vis_packet->sender_orig))
return NET_RX_DROP;
+ /* FIXME: each batman_if will be attached to a softif */
+ bat_priv = netdev_priv(soft_device);
+
switch (vis_packet->vis_type) {
case VIS_TYPE_SERVER_SYNC:
/* TODO: handle fragmented skbs properly */
- receive_server_sync_packet(vis_packet, skb_headlen(skb));
+ receive_server_sync_packet(bat_priv, vis_packet,
+ skb_headlen(skb));
break;
case VIS_TYPE_CLIENT_UPDATE:
/* TODO: handle fragmented skbs properly */
- receive_client_update_packet(vis_packet, skb_headlen(skb));
+ receive_client_update_packet(bat_priv, vis_packet,
+ skb_headlen(skb));
break;
default: /* ignore unknown packet */
Modified: trunk/batman-adv-kernelland/routing.h
===================================================================
--- trunk/batman-adv-kernelland/routing.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/routing.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -38,5 +38,5 @@
int recv_bat_packet(struct sk_buff *skb,
struct batman_if *batman_if);
struct neigh_node *find_router(struct orig_node *orig_node);
-void update_bonding_candidates(struct orig_node *orig_node,
- struct bat_priv *bat_priv);
+void update_bonding_candidates(struct bat_priv *bat_priv,
+ struct orig_node *orig_node);
Modified: trunk/batman-adv-kernelland/send.c
===================================================================
--- trunk/batman-adv-kernelland/send.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/send.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -245,7 +245,7 @@
struct bat_priv *bat_priv = netdev_priv(soft_device);
unsigned long send_time;
struct batman_packet *batman_packet;
- int vis_server = atomic_read(&vis_mode);
+ int vis_server = atomic_read(&bat_priv->vis_mode);
/**
* the interface gets activated here to avoid race conditions between
@@ -275,17 +275,21 @@
else
batman_packet->flags &= ~VIS_SERVER;
- batman_packet->gw_flags = (uint8_t)atomic_read(&gw_srv_class);
+ if (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER)
+ batman_packet->gw_flags =
+ (uint8_t)atomic_read(&bat_priv->gw_class);
+ else
+ batman_packet->gw_flags = 0;
/* could be read by receive_bat_packet() */
atomic_inc(&batman_if->seqno);
slide_own_bcast_window(batman_if);
send_time = own_send_time();
- add_bat_packet_to_list(batman_if->packet_buff,
+ add_bat_packet_to_list(bat_priv,
+ batman_if->packet_buff,
batman_if->packet_len,
- batman_if, 1, send_time,
- bat_priv);
+ batman_if, 1, send_time);
}
void schedule_forward_packet(struct orig_node *orig_node,
@@ -342,10 +346,10 @@
batman_packet->flags &= ~DIRECTLINK;
send_time = forward_send_time(bat_priv);
- add_bat_packet_to_list((unsigned char *)batman_packet,
+ add_bat_packet_to_list(bat_priv,
+ (unsigned char *)batman_packet,
sizeof(struct batman_packet) + hna_buff_len,
- if_incoming, 0, send_time,
- bat_priv);
+ if_incoming, 0, send_time);
}
static void forw_packet_free(struct forw_packet *forw_packet)
Modified: trunk/batman-adv-kernelland/soft-interface.c
===================================================================
--- trunk/batman-adv-kernelland/soft-interface.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/soft-interface.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -187,6 +187,7 @@
struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct bat_priv *priv = netdev_priv(dev);
struct batman_if *batman_if;
+ struct bat_priv *bat_priv;
uint8_t dstaddr[6];
int data_len = skb->len;
unsigned long flags;
@@ -195,6 +196,9 @@
if (atomic_read(&module_state) != MODULE_ACTIVE)
goto dropped;
+ /* FIXME: each batman_if will be attached to a softif */
+ bat_priv = netdev_priv(soft_device);
+
dev->trans_start = jiffies;
/* TODO: check this for locks */
hna_local_add(ethhdr->h_source);
@@ -202,7 +206,7 @@
if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest))
bcast_dst = true;
- if ((bcast_dst) && gw_is_target(skb))
+ if ((bcast_dst) && gw_is_target(bat_priv, skb))
do_bcast = false;
/* ethernet packet should be broadcasted */
Modified: trunk/batman-adv-kernelland/translation-table.c
===================================================================
--- trunk/batman-adv-kernelland/translation-table.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/translation-table.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -166,6 +166,19 @@
unsigned long flags;
size_t hdr_len;
+ rcu_read_lock();
+ if (list_empty(&if_list)) {
+ rcu_read_unlock();
+
+ if (off == 0)
+ return sprintf(buff,
+ "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+ net_dev->name);
+
+ return 0;
+ }
+ rcu_read_unlock();
+
hdr_len = sprintf(buff,
"Locally retrieved addresses (from %s) announced via HNA:\n",
net_dev->name);
@@ -370,6 +383,19 @@
unsigned long flags;
size_t hdr_len;
+ rcu_read_lock();
+ if (list_empty(&if_list)) {
+ rcu_read_unlock();
+
+ if (off == 0)
+ return sprintf(buff,
+ "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+ net_dev->name);
+
+ return 0;
+ }
+ rcu_read_unlock();
+
hdr_len = sprintf(buff,
"Globally announced HNAs received via the mesh %s (translation table):\n",
net_dev->name);
Modified: trunk/batman-adv-kernelland/types.h
===================================================================
--- trunk/batman-adv-kernelland/types.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/types.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -96,6 +96,9 @@
struct net_device_stats stats;
atomic_t aggregation_enabled;
atomic_t bonding_enabled;
+ atomic_t vis_mode;
+ atomic_t gw_mode;
+ atomic_t gw_class;
struct kobject *mesh_obj;
};
Modified: trunk/batman-adv-kernelland/vis.c
===================================================================
--- trunk/batman-adv-kernelland/vis.c 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/vis.c 2010-03-21 22:05:34 UTC (rev 1608)
@@ -103,7 +103,7 @@
/* insert interface to the list of interfaces of one originator, if it
* does not already exist in the list */
-void proc_vis_insert_interface(const uint8_t *interface,
+void vis_data_insert_interface(const uint8_t *interface,
struct hlist_head *if_list,
bool primary)
{
@@ -124,38 +124,121 @@
hlist_add_head(&entry->list, if_list);
}
-void proc_vis_read_prim_sec(struct seq_file *seq,
- struct hlist_head *if_list)
+ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list)
{
struct if_list_entry *entry;
struct hlist_node *pos;
char tmp_addr_str[ETH_STR_LEN];
+ size_t len = 0;
hlist_for_each_entry(entry, pos, if_list, list) {
if (entry->primary)
- seq_printf(seq, "PRIMARY, ");
+ len += sprintf(buff + len, "PRIMARY, ");
else {
addr_to_string(tmp_addr_str, entry->addr);
- seq_printf(seq, "SEC %s, ", tmp_addr_str);
+ len += sprintf(buff + len, "SEC %s, ", tmp_addr_str);
}
}
+
+ return len;
}
/* read an entry */
-void proc_vis_read_entry(struct seq_file *seq,
- struct vis_info_entry *entry,
- uint8_t *src,
- bool primary)
+ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry,
+ uint8_t *src, bool primary)
{
char to[40];
addr_to_string(to, entry->dest);
if (primary && entry->quality == 0)
- seq_printf(seq, "HNA %s, ", to);
+ return sprintf(buff, "HNA %s, ", to);
else if (compare_orig(entry->src, src))
- seq_printf(seq, "TQ %s %d, ", to, entry->quality);
+ return sprintf(buff, "TQ %s %d, ", to, entry->quality);
+
+ return 0;
}
+ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,
+ size_t count, loff_t off)
+{
+ HASHIT(hashit);
+ struct vis_info *info;
+ struct vis_info_entry *entries;
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ HLIST_HEAD(vis_if_list);
+ struct if_list_entry *entry;
+ struct hlist_node *pos, *n;
+ size_t hdr_len, tmp_len;
+ int i, bytes_written = 0;
+ char tmp_addr_str[ETH_STR_LEN];
+ unsigned long flags;
+ int vis_server = atomic_read(&bat_priv->vis_mode);
+
+ rcu_read_lock();
+ if (list_empty(&if_list) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) {
+ rcu_read_unlock();
+ return 0;
+ }
+
+ rcu_read_unlock();
+ hdr_len = 0;
+
+ spin_lock_irqsave(&vis_hash_lock, flags);
+ while (hash_iterate(vis_hash, &hashit)) {
+ info = hashit.bucket->data;
+ entries = (struct vis_info_entry *)
+ ((char *)info + sizeof(struct vis_info));
+
+ /* estimated line length */
+ if (count < bytes_written + 200)
+ break;
+
+ for (i = 0; i < info->packet.entries; i++) {
+ if (entries[i].quality == 0)
+ continue;
+ vis_data_insert_interface(entries[i].src, &vis_if_list,
+ compare_orig(entries[i].src,
+ info->packet.vis_orig));
+ }
+
+ hlist_for_each_entry(entry, pos, &vis_if_list, list) {
+ addr_to_string(tmp_addr_str, entry->addr);
+ tmp_len = sprintf(buff + bytes_written,
+ "%s,", tmp_addr_str);
+
+ for (i = 0; i < info->packet.entries; i++)
+ tmp_len += vis_data_read_entry(
+ buff + bytes_written + tmp_len,
+ &entries[i], entry->addr,
+ entry->primary);
+
+ /* add primary/secondary records */
+ if (compare_orig(entry->addr, info->packet.vis_orig))
+ tmp_len += vis_data_read_prim_sec(
+ buff + bytes_written + tmp_len,
+ &vis_if_list);
+
+ tmp_len += sprintf(buff + bytes_written + tmp_len,
+ "\n");
+
+ hdr_len += tmp_len;
+
+ if (off >= hdr_len)
+ continue;
+
+ bytes_written += tmp_len;
+ }
+
+ hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) {
+ hlist_del(&entry->list);
+ kfree(entry);
+ }
+ }
+ spin_unlock_irqrestore(&vis_hash_lock, flags);
+
+ return bytes_written;
+}
+
/* add the info packet to the send list, if it was not
* already linked in. */
static void send_list_add(struct vis_info *info)
@@ -281,12 +364,14 @@
}
/* handle the server sync packet, forward if needed. */
-void receive_server_sync_packet(struct vis_packet *vis_packet, int vis_info_len)
+void receive_server_sync_packet(struct bat_priv *bat_priv,
+ struct vis_packet *vis_packet,
+ int vis_info_len)
{
struct vis_info *info;
int is_new, make_broadcast;
unsigned long flags;
- int vis_server = atomic_read(&vis_mode);
+ int vis_server = atomic_read(&bat_priv->vis_mode);
make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC);
@@ -304,13 +389,14 @@
}
/* handle an incoming client update packet and schedule forward if needed. */
-void receive_client_update_packet(struct vis_packet *vis_packet,
+void receive_client_update_packet(struct bat_priv *bat_priv,
+ struct vis_packet *vis_packet,
int vis_info_len)
{
struct vis_info *info;
int is_new;
unsigned long flags;
- int vis_server = atomic_read(&vis_mode);
+ int vis_server = atomic_read(&bat_priv->vis_mode);
int are_target = 0;
/* clients shall not broadcast. */
@@ -377,7 +463,7 @@
/* generates a packet of own vis data,
* returns 0 on success, -1 if no packet could be generated */
-static int generate_vis_packet(void)
+static int generate_vis_packet(struct bat_priv *bat_priv)
{
HASHIT(hashit_local);
HASHIT(hashit_global);
@@ -389,7 +475,7 @@
unsigned long flags;
info->first_seen = jiffies;
- info->packet.vis_type = atomic_read(&vis_mode);
+ info->packet.vis_type = atomic_read(&bat_priv->vis_mode);
spin_lock_irqsave(&orig_hash_lock, flags);
memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN);
@@ -569,12 +655,14 @@
{
struct vis_info *info, *temp;
unsigned long flags;
+ /* FIXME: each batman_if will be attached to a softif */
+ struct bat_priv *bat_priv = netdev_priv(soft_device);
spin_lock_irqsave(&vis_hash_lock, flags);
purge_vis_packets();
- if (generate_vis_packet() == 0) {
+ if (generate_vis_packet(bat_priv) == 0) {
/* schedule if generation was successful */
send_list_add(my_vis_info);
}
Modified: trunk/batman-adv-kernelland/vis.h
===================================================================
--- trunk/batman-adv-kernelland/vis.h 2010-03-21 21:34:03 UTC (rev 1607)
+++ trunk/batman-adv-kernelland/vis.h 2010-03-21 22:05:34 UTC (rev 1608)
@@ -47,18 +47,13 @@
extern struct hashtable_t *vis_hash;
extern spinlock_t vis_hash_lock;
-void proc_vis_insert_interface(const uint8_t *interface,
- struct hlist_head *if_list,
- bool primary);
-void proc_vis_read_entry(struct seq_file *seq,
- struct vis_info_entry *entry,
- uint8_t *src,
- bool primary);
-void proc_vis_read_prim_sec(struct seq_file *seq,
- struct hlist_head *if_list);
-void receive_server_sync_packet(struct vis_packet *vis_packet,
+ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,
+ size_t count, loff_t off);
+void receive_server_sync_packet(struct bat_priv *bat_priv,
+ struct vis_packet *vis_packet,
int vis_info_len);
-void receive_client_update_packet(struct vis_packet *vis_packet,
+void receive_client_update_packet(struct bat_priv *bat_priv,
+ struct vis_packet *vis_packet,
int vis_info_len);
int vis_init(void);
void vis_quit(void);
11 years
r1607 - branches/batctl-0.2.x/man
by postmaster@open-mesh.net
Author: simon
Date: 2010-03-21 22:34:03 +0100 (Sun, 21 Mar 2010)
New Revision: 1607
Modified:
branches/batctl-0.2.x/man/batctl.8
Log:
batctl-0.2.x: adjust "-w" option, vis options and minor layout things
This patch adds documentation for the new way of enabling/disabling
and handling the vis server. It also adds documentation for the change
from "-b" to "-w" in the according options. Furthermore, the sub-option
alignment has been altered in some places.
Signed-off-by: Linus L?\195?\188ssing <linus.luessing(a)web.de>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: branches/batctl-0.2.x/man/batctl.8
===================================================================
--- branches/batctl-0.2.x/man/batctl.8 2010-03-21 20:44:37 UTC (rev 1606)
+++ branches/batctl-0.2.x/man/batctl.8 2010-03-21 21:34:03 UTC (rev 1607)
@@ -58,10 +58,9 @@
otherwise the parameter(s) are added as new interfaces. Use the "none"
keyword to deactivate all interfaces.
.br
-.IP "\fBoriginators\fP|\fBo\fP [\fB\-b\fP][\fB\-n\fP]"
-Display the originator table. Once started batctl will refresh the
-displayed originator table every second. The "\-b" option causes the
-table to be displayed only once (useful for scripts). If "\-n" is
+.IP "\fBoriginators\fP|\fBo\fP [\fB\-w\fP][\fB\-n\fP]"
+Once started batctl will display the originator table. Use the "\-w"
+option to let batctl refresh the list every second. If "\-n" is
given batctl will not replace the MAC addresses with bat\-host names
in the output.
.br
@@ -73,42 +72,38 @@
.IP "\fBloglevel\fP|\fBll\fP [\fIlevel\fP]"
If no parameter is given the current log level settings are displayed
otherwise the parameter is used to set the log level. Level 0 disables
-all logging. Level 1 enables messages related to routing / flooding /
-broadcasting. Level 2 enables messages related to route or hna added /
-changed / deleted. Level 3 enables all messages. The messages are sent
-to the kernel log. Use \fBdmesg\fP(1) to see them.
+all verbose logging. Level 1 enables messages related to routing / flooding / broadcasting.
+Level 2 enables messages related to route or hna added / changed / deleted.
+Level 3 enables all messages. The messages are sent to the kernel log.
+Use \fBdmesg\fP(1) to see them. Make sure to have debugging output
+enabled when compiling the module otherwise the verbose logging output as
+well as the loglevel options won't be available.
.br
-.IP "\fBlog\fP|\fBl\fP [\fIlogfile\fP][\fB\-b\fP][\fB\-n\fP]\fP"
+.IP "\fBlog\fP|\fBl\fP [\fIlogfile\fP][\fB\-w\fP][\fB\-n\fP]\fP"
batctl will read the file logfile, or stdin if the logfile parameter
is not given, applying filtering so only the B.A.T.M.A.N. Advanced
-messages are displayed. Whenever there are new log messages appended
-to the file batctl will display them. The option "\-b" causes batctl
-to exit once the end of the file has been reached. If "\-n" is given
-batctl will not replace the MAC addresses with bat\-host names in the
-output.
+messages are displayed. Once the end of the file has been reached batctl
+will exit unless the option "\-w" was specified which causes batctl to
+continue reading the file and print log output whenever new log data has
+been appended to the file. If "\-n" is given batctl will not replace the
+MAC addresses with bat\-host names in the output.
.br
-.IP "\fBtranslocal\fP|\fBtl\fP [\fB\-b\fP][\fB\-n\fP]"
-Display the local translation table. batctl will refresh the
-displayed table every second. The "\-b" option causes the table to be
-displayed only once (useful for scripts). If "\-n" is given batctl
-will not replace the MAC addresses with bat\-host names in the output.
+.IP "\fBtranslocal\fP|\fBtl\fP [\fB\-w\fP][\fB\-n\fP]"
+Display the local translation table. Use the "\-w" option to let batctl
+refresh the list every second. If "\-n" is given batctl will not replace
+the MAC addresses with bat\-host names in the output.
.br
-.IP "\fBtransglobal\fP|\fBtg\fP [\fB\-b\fP][\fB\-n\fP]"
-Display the global translation table. batctl will refresh the
-displayed table every second. The "\-b" option causes the table to be
-displayed only once (useful for scripts). If "\-n" is given batctl
-will not replace the MAC addresses with bat\-host names in the output.
+.IP "\fBtransglobal\fP|\fBtg\fP [\fB\-w\fP][\fB\-n\fP]"
+Display the global translation table. Use the "\-w" option to let batctl
+refresh the list every second. If "\-n" is given batctl will not replace
+the MAC addresses with bat\-host names in the output.
.br
-.IP "\fBvis dot\fP [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
-Display the visualisation data in graphviz \fBdot\fP(1) format. If
-"\-\-numbers" or "\-n" is given batctl will not replace the MAC
-addresses with bat-host names in the output. With "\-\-no-HNA" or
-"\-H" the HNA entries are not displayed, so the pure mesh topology can
-be seen. With "\-\-no-2nd" or "\-2" a dot cluster is not formed around
-primary and secondary addresses from the same device.
+.IP "\fBvis_server\fP|\fBvs\fP [\fBenabled\fP|\fBdisabled\fP]"
+If no parameter is given the current vis server setting is displayed.
+Otherwise the parameter is used to enable or disable the vis server.
.br
-.IP "\fBvis json\fP [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
-Display the visualisation data in JSON format. If "\-\-numbers" or
+.IP "\fBvis_data\fP|\fBvd\fP \fBdot|\fBjson [\fB\-n\fP|\fB\-\-numbers\fP][\fB\-H\fP|\fB\-\-no-HNA\fP][\fB\-2\fP|\fB\-\-no-2nd\fP]"
+Display the visualisation data in \fBdot\fP(1) or JSON format. If "\-\-numbers" or
"\-n" is given batctl will not replace the MAC addresses with bat-host
names in the output. With "\-\-no-HNA" or "\-H" the HNA entries are
not displayed, so the pure mesh topology can be seen. With
@@ -129,14 +124,14 @@
you can set the default interval between pings and the timeout time
for replies, both in seconds.
.br
-.IP "\fBtraceroute\fP|\fBtr\fP [\fB\-n\fP] \fIMAC_address\fP|\fIbat\-host_name\fP"
+.IP "\fBtraceroute\fP|\fBtr\fP [\fB\-n\fP] \fIMAC_address\fP|\fBbat\-host_name\fP"
Layer 2 traceroute to a MAC address or bat\-host name. batctl will try
to find the bat\-host name if the given parameter was not a MAC
address. batctl will send 3 packets to each host and display the
response time. If "\-n" is given batctl will not replace the MAC
addresses with bat\-host names in the output.
.br
-.IP "\fBtcpdump\fP|\fBtd\fP [\fB\-p \fP\fIfilter\fP][\fB\-n\fP] \fIinterface ...\fP"
+.IP "\fBtcpdump\fP|\fBtd\fP [\fB\-p \fP\fIfilter\fP][\fB\-n\fP] \fBinterface ...\fP"
batctl will display all packets that are seen on the given
interface(s). The "\-p" options allows the filtering of certain packet
types: 1 - batman ogm packets, 2 - batman icmp packets, 4 - unicast
@@ -146,7 +141,7 @@
packets only. If "\-n" is given batctl will not replace the MAC
addresses with bat\-host names in the output.
.br
-.IP "\fBbisect\fP [\fB\-l \fP\fIMAC\fP][\fB\-t \fP\fIMAC\fP][\fB\-r \fP\fIMAC\fP][\fB\-s \fP\fImin\fP [\fB\- \fP\fImax\fP]][\fB\-o \fP\fIMAC\fP][\fB\-n\fP] \fIlogfile1\fP [\fIlogfile2\fP ... \fIlogfileN\fP]"
+.IP "\fBbisect\fP [\fB\-l \fP\fIMAC\fP][\fB\-t \fP\fIMAC\fP][\fB\-r \fP\fIMAC\fP][\fB\-s \fP\fImin\fP [\fB\- \fP\fImax\fP]][\fB\-o \fP\fIMAC\fP][\fB\-n\fP] \fIlogfile1\fP [\fIlogfile2\fP ... \fIlogfileN\fP]"
Analyses the logfiles to build a small internal database of all sent
sequence numbers and routing table changes. This database can then be
analyzed in a number of different ways. With "\-l" the database can be
11 years