diff options
-rw-r--r-- | drivers/staging/batman-adv/aggregation.c | 6 | ||||
-rw-r--r-- | drivers/staging/batman-adv/aggregation.h | 8 | ||||
-rw-r--r-- | drivers/staging/batman-adv/bat_sysfs.c | 118 | ||||
-rw-r--r-- | drivers/staging/batman-adv/main.c | 2 | ||||
-rw-r--r-- | drivers/staging/batman-adv/main.h | 1 | ||||
-rw-r--r-- | drivers/staging/batman-adv/originator.c | 33 | ||||
-rw-r--r-- | drivers/staging/batman-adv/originator.h | 3 | ||||
-rw-r--r-- | drivers/staging/batman-adv/proc.c | 167 | ||||
-rw-r--r-- | drivers/staging/batman-adv/proc.h | 5 | ||||
-rw-r--r-- | drivers/staging/batman-adv/routing.c | 10 | ||||
-rw-r--r-- | drivers/staging/batman-adv/send.c | 16 | ||||
-rw-r--r-- | drivers/staging/batman-adv/soft-interface.c | 4 | ||||
-rw-r--r-- | drivers/staging/batman-adv/translation-table.c | 26 | ||||
-rw-r--r-- | drivers/staging/batman-adv/types.h | 1 | ||||
-rw-r--r-- | drivers/staging/batman-adv/vis.c | 124 | ||||
-rw-r--r-- | drivers/staging/batman-adv/vis.h | 17 |
16 files changed, 265 insertions, 276 deletions
diff --git a/drivers/staging/batman-adv/aggregation.c b/drivers/staging/batman-adv/aggregation.c index c9468390878..a5818ff6139 100644 --- a/drivers/staging/batman-adv/aggregation.c +++ b/drivers/staging/batman-adv/aggregation.c | |||
@@ -165,10 +165,10 @@ static void aggregate(struct forw_packet *forw_packet_aggr, | |||
165 | (1 << forw_packet_aggr->num_packets); | 165 | (1 << forw_packet_aggr->num_packets); |
166 | } | 166 | } |
167 | 167 | ||
168 | void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, | 168 | void add_bat_packet_to_list(struct bat_priv *bat_priv, |
169 | unsigned char *packet_buff, int packet_len, | ||
169 | struct batman_if *if_incoming, char own_packet, | 170 | struct batman_if *if_incoming, char own_packet, |
170 | unsigned long send_time, | 171 | unsigned long send_time) |
171 | struct bat_priv *bat_priv) | ||
172 | { | 172 | { |
173 | /** | 173 | /** |
174 | * _aggr -> pointer to the packet we want to aggregate with | 174 | * _aggr -> pointer to the packet we want to aggregate with |
diff --git a/drivers/staging/batman-adv/aggregation.h b/drivers/staging/batman-adv/aggregation.h index 29e1ffcbc7f..84401ca24c3 100644 --- a/drivers/staging/batman-adv/aggregation.h +++ b/drivers/staging/batman-adv/aggregation.h | |||
@@ -30,9 +30,9 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_hna) | |||
30 | (next_buff_pos <= MAX_AGGREGATION_BYTES); | 30 | (next_buff_pos <= MAX_AGGREGATION_BYTES); |
31 | } | 31 | } |
32 | 32 | ||
33 | void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, | 33 | void add_bat_packet_to_list(struct bat_priv *bat_priv, |
34 | struct batman_if *if_outgoing, char own_packet, | 34 | unsigned char *packet_buff, int packet_len, |
35 | unsigned long send_time, | 35 | struct batman_if *if_incoming, char own_packet, |
36 | struct bat_priv *bat_priv); | 36 | unsigned long send_time); |
37 | void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, | 37 | void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, |
38 | int packet_len, struct batman_if *if_incoming); | 38 | int packet_len, struct batman_if *if_incoming); |
diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index 62931186ff3..c14ab47fc5a 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "translation-table.h" | 24 | #include "translation-table.h" |
25 | #include "originator.h" | 25 | #include "originator.h" |
26 | #include "hard-interface.h" | 26 | #include "hard-interface.h" |
27 | #include "vis.h" | ||
27 | 28 | ||
28 | #define to_dev(obj) container_of(obj, struct device, kobj) | 29 | #define to_dev(obj) container_of(obj, struct device, kobj) |
29 | 30 | ||
@@ -99,11 +100,66 @@ static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr, | |||
99 | return count; | 100 | return count; |
100 | } | 101 | } |
101 | 102 | ||
103 | static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, | ||
104 | char *buff) | ||
105 | { | ||
106 | struct device *dev = to_dev(kobj->parent); | ||
107 | struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); | ||
108 | int vis_mode = atomic_read(&bat_priv->vis_mode); | ||
109 | |||
110 | return sprintf(buff, "status: %s\ncommands: client, server, %d, %d \n", | ||
111 | vis_mode == VIS_TYPE_CLIENT_UPDATE ? | ||
112 | "client" : "server", | ||
113 | VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE); | ||
114 | } | ||
115 | |||
116 | static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, | ||
117 | char *buff, size_t count) | ||
118 | { | ||
119 | struct device *dev = to_dev(kobj->parent); | ||
120 | struct net_device *net_dev = to_net_dev(dev); | ||
121 | struct bat_priv *bat_priv = netdev_priv(net_dev); | ||
122 | unsigned long val; | ||
123 | int ret, vis_mode_tmp = -1; | ||
124 | |||
125 | ret = strict_strtoul(buff, 10, &val); | ||
126 | |||
127 | if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || | ||
128 | (strncmp(buff, "client", 6) == 0)) | ||
129 | vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE; | ||
130 | |||
131 | if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) || | ||
132 | (strncmp(buff, "server", 6) == 0)) | ||
133 | vis_mode_tmp = VIS_TYPE_SERVER_SYNC; | ||
134 | |||
135 | if (vis_mode_tmp < 0) { | ||
136 | if (buff[count - 1] == '\n') | ||
137 | buff[count - 1] = '\0'; | ||
138 | |||
139 | printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n", | ||
140 | net_dev->name, buff); | ||
141 | return -EINVAL; | ||
142 | } | ||
143 | |||
144 | if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) | ||
145 | return count; | ||
146 | |||
147 | printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n", | ||
148 | atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ? | ||
149 | "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? | ||
150 | "client" : "server", net_dev->name); | ||
151 | |||
152 | atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp); | ||
153 | return count; | ||
154 | } | ||
155 | |||
102 | static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, | 156 | static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, |
103 | show_aggr_ogm, store_aggr_ogm); | 157 | show_aggr_ogm, store_aggr_ogm); |
158 | static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); | ||
104 | 159 | ||
105 | static struct bat_attribute *mesh_attrs[] = { | 160 | static struct bat_attribute *mesh_attrs[] = { |
106 | &bat_attr_aggregate_ogm, | 161 | &bat_attr_aggregate_ogm, |
162 | &bat_attr_vis_mode, | ||
107 | NULL, | 163 | NULL, |
108 | }; | 164 | }; |
109 | 165 | ||
@@ -114,19 +170,6 @@ static ssize_t transtable_local_read(struct kobject *kobj, | |||
114 | struct device *dev = to_dev(kobj->parent); | 170 | struct device *dev = to_dev(kobj->parent); |
115 | struct net_device *net_dev = to_net_dev(dev); | 171 | struct net_device *net_dev = to_net_dev(dev); |
116 | 172 | ||
117 | rcu_read_lock(); | ||
118 | if (list_empty(&if_list)) { | ||
119 | rcu_read_unlock(); | ||
120 | |||
121 | if (off == 0) | ||
122 | return sprintf(buff, | ||
123 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
124 | net_dev->name); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | rcu_read_unlock(); | ||
129 | |||
130 | return hna_local_fill_buffer_text(net_dev, buff, count, off); | 173 | return hna_local_fill_buffer_text(net_dev, buff, count, off); |
131 | } | 174 | } |
132 | 175 | ||
@@ -137,19 +180,6 @@ static ssize_t transtable_global_read(struct kobject *kobj, | |||
137 | struct device *dev = to_dev(kobj->parent); | 180 | struct device *dev = to_dev(kobj->parent); |
138 | struct net_device *net_dev = to_net_dev(dev); | 181 | struct net_device *net_dev = to_net_dev(dev); |
139 | 182 | ||
140 | rcu_read_lock(); | ||
141 | if (list_empty(&if_list)) { | ||
142 | rcu_read_unlock(); | ||
143 | |||
144 | if (off == 0) | ||
145 | return sprintf(buff, | ||
146 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
147 | net_dev->name); | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | rcu_read_unlock(); | ||
152 | |||
153 | return hna_global_fill_buffer_text(net_dev, buff, count, off); | 183 | return hna_global_fill_buffer_text(net_dev, buff, count, off); |
154 | } | 184 | } |
155 | 185 | ||
@@ -157,45 +187,32 @@ static ssize_t originators_read(struct kobject *kobj, | |||
157 | struct bin_attribute *bin_attr, | 187 | struct bin_attribute *bin_attr, |
158 | char *buff, loff_t off, size_t count) | 188 | char *buff, loff_t off, size_t count) |
159 | { | 189 | { |
160 | /* FIXME: orig table should exist per batif */ | ||
161 | struct device *dev = to_dev(kobj->parent); | 190 | struct device *dev = to_dev(kobj->parent); |
162 | struct net_device *net_dev = to_net_dev(dev); | 191 | struct net_device *net_dev = to_net_dev(dev); |
163 | 192 | ||
164 | rcu_read_lock(); | 193 | return orig_fill_buffer_text(net_dev, buff, count, off); |
165 | if (list_empty(&if_list)) { | 194 | } |
166 | rcu_read_unlock(); | ||
167 | |||
168 | if (off == 0) | ||
169 | return sprintf(buff, | ||
170 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
171 | net_dev->name); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) { | ||
177 | rcu_read_unlock(); | ||
178 | |||
179 | if (off == 0) | ||
180 | return sprintf(buff, | ||
181 | "BATMAN mesh %s disabled - primary interface not active\n", | ||
182 | net_dev->name); | ||
183 | 195 | ||
184 | return 0; | 196 | static ssize_t vis_data_read(struct kobject *kobj, |
185 | } | 197 | struct bin_attribute *bin_attr, |
186 | rcu_read_unlock(); | 198 | char *buff, loff_t off, size_t count) |
199 | { | ||
200 | struct device *dev = to_dev(kobj->parent); | ||
201 | struct net_device *net_dev = to_net_dev(dev); | ||
187 | 202 | ||
188 | return orig_fill_buffer_text(buff, count, off); | 203 | return vis_fill_buffer_text(net_dev, buff, count, off); |
189 | } | 204 | } |
190 | 205 | ||
191 | static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL); | 206 | static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL); |
192 | static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL); | 207 | static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL); |
193 | static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL); | 208 | static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL); |
209 | static BAT_BIN_ATTR(vis_data, S_IRUGO, vis_data_read, NULL); | ||
194 | 210 | ||
195 | static struct bin_attribute *mesh_bin_attrs[] = { | 211 | static struct bin_attribute *mesh_bin_attrs[] = { |
196 | &bat_attr_transtable_local, | 212 | &bat_attr_transtable_local, |
197 | &bat_attr_transtable_global, | 213 | &bat_attr_transtable_global, |
198 | &bat_attr_originators, | 214 | &bat_attr_originators, |
215 | &bat_attr_vis_data, | ||
199 | NULL, | 216 | NULL, |
200 | }; | 217 | }; |
201 | 218 | ||
@@ -210,6 +227,7 @@ int sysfs_add_meshif(struct net_device *dev) | |||
210 | /* FIXME: should be done in the general mesh setup | 227 | /* FIXME: should be done in the general mesh setup |
211 | routine as soon as we have it */ | 228 | routine as soon as we have it */ |
212 | atomic_set(&bat_priv->aggregation_enabled, 1); | 229 | atomic_set(&bat_priv->aggregation_enabled, 1); |
230 | atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); | ||
213 | 231 | ||
214 | bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, | 232 | bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, |
215 | batif_kobject); | 233 | batif_kobject); |
diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c index b5f8b800974..54e8cd5a32f 100644 --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c | |||
@@ -44,7 +44,6 @@ DEFINE_SPINLOCK(forw_bcast_list_lock); | |||
44 | 44 | ||
45 | atomic_t originator_interval; | 45 | atomic_t originator_interval; |
46 | atomic_t vis_interval; | 46 | atomic_t vis_interval; |
47 | atomic_t vis_mode; | ||
48 | int16_t num_hna; | 47 | int16_t num_hna; |
49 | int16_t num_ifs; | 48 | int16_t num_ifs; |
50 | 49 | ||
@@ -84,7 +83,6 @@ int init_module(void) | |||
84 | atomic_set(&originator_interval, 1000); | 83 | atomic_set(&originator_interval, 1000); |
85 | atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only | 84 | atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only |
86 | * for debugging now. */ | 85 | * for debugging now. */ |
87 | atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE); | ||
88 | 86 | ||
89 | /* the name should not be longer than 10 chars - see | 87 | /* the name should not be longer than 10 chars - see |
90 | * http://lwn.net/Articles/23634/ */ | 88 | * http://lwn.net/Articles/23634/ */ |
diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h index 3e28e9ef79b..b2283a75ee6 100644 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h | |||
@@ -129,7 +129,6 @@ extern spinlock_t forw_bcast_list_lock; | |||
129 | 129 | ||
130 | extern atomic_t originator_interval; | 130 | extern atomic_t originator_interval; |
131 | extern atomic_t vis_interval; | 131 | extern atomic_t vis_interval; |
132 | extern atomic_t vis_mode; | ||
133 | extern int16_t num_hna; | 132 | extern int16_t num_hna; |
134 | extern int16_t num_ifs; | 133 | extern int16_t num_ifs; |
135 | 134 | ||
diff --git a/drivers/staging/batman-adv/originator.c b/drivers/staging/batman-adv/originator.c index 818f56e55f2..684db750cf1 100644 --- a/drivers/staging/batman-adv/originator.c +++ b/drivers/staging/batman-adv/originator.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "hash.h" | 26 | #include "hash.h" |
27 | #include "translation-table.h" | 27 | #include "translation-table.h" |
28 | #include "routing.h" | 28 | #include "routing.h" |
29 | #include "hard-interface.h" | ||
29 | 30 | ||
30 | static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig); | 31 | static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig); |
31 | 32 | ||
@@ -205,7 +206,6 @@ static bool purge_orig_neighbors(struct orig_node *orig_node, | |||
205 | return neigh_purged; | 206 | return neigh_purged; |
206 | } | 207 | } |
207 | 208 | ||
208 | |||
209 | static bool purge_orig_node(struct orig_node *orig_node) | 209 | static bool purge_orig_node(struct orig_node *orig_node) |
210 | { | 210 | { |
211 | struct neigh_node *best_neigh_node; | 211 | struct neigh_node *best_neigh_node; |
@@ -224,6 +224,7 @@ static bool purge_orig_node(struct orig_node *orig_node) | |||
224 | orig_node->hna_buff, | 224 | orig_node->hna_buff, |
225 | orig_node->hna_buff_len); | 225 | orig_node->hna_buff_len); |
226 | } | 226 | } |
227 | |||
227 | return false; | 228 | return false; |
228 | } | 229 | } |
229 | 230 | ||
@@ -249,7 +250,8 @@ void purge_orig(struct work_struct *work) | |||
249 | start_purge_timer(); | 250 | start_purge_timer(); |
250 | } | 251 | } |
251 | 252 | ||
252 | ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off) | 253 | ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, |
254 | size_t count, loff_t off) | ||
253 | { | 255 | { |
254 | HASHIT(hashit); | 256 | HASHIT(hashit); |
255 | struct orig_node *orig_node; | 257 | struct orig_node *orig_node; |
@@ -260,12 +262,35 @@ ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off) | |||
260 | char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN]; | 262 | char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN]; |
261 | 263 | ||
262 | rcu_read_lock(); | 264 | rcu_read_lock(); |
265 | if (list_empty(&if_list)) { | ||
266 | rcu_read_unlock(); | ||
267 | |||
268 | if (off == 0) | ||
269 | return sprintf(buff, | ||
270 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
271 | net_dev->name); | ||
272 | |||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) { | ||
277 | rcu_read_unlock(); | ||
278 | |||
279 | if (off == 0) | ||
280 | return sprintf(buff, | ||
281 | "BATMAN mesh %s disabled - primary interface not active\n", | ||
282 | net_dev->name); | ||
283 | |||
284 | return 0; | ||
285 | } | ||
286 | |||
263 | hdr_len = sprintf(buff, | 287 | hdr_len = sprintf(buff, |
264 | " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n", | 288 | " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n", |
265 | "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", | 289 | "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", |
266 | "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR, | 290 | "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR, |
267 | ((struct batman_if *)if_list.next)->dev, | 291 | ((struct batman_if *)if_list.next)->dev, |
268 | ((struct batman_if *)if_list.next)->addr_str); | 292 | ((struct batman_if *)if_list.next)->addr_str, |
293 | net_dev->name); | ||
269 | rcu_read_unlock(); | 294 | rcu_read_unlock(); |
270 | 295 | ||
271 | if (off < hdr_len) | 296 | if (off < hdr_len) |
diff --git a/drivers/staging/batman-adv/originator.h b/drivers/staging/batman-adv/originator.h index 8289a85342a..745b4b064c1 100644 --- a/drivers/staging/batman-adv/originator.h +++ b/drivers/staging/batman-adv/originator.h | |||
@@ -28,4 +28,5 @@ struct orig_node *get_orig_node(uint8_t *addr); | |||
28 | struct neigh_node * | 28 | struct neigh_node * |
29 | create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, | 29 | create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, |
30 | uint8_t *neigh, struct batman_if *if_incoming); | 30 | uint8_t *neigh, struct batman_if *if_incoming); |
31 | ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off); | 31 | ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, |
32 | size_t count, loff_t off); | ||
diff --git a/drivers/staging/batman-adv/proc.c b/drivers/staging/batman-adv/proc.c index 059b2d9ffa8..cbea64212db 100644 --- a/drivers/staging/batman-adv/proc.c +++ b/drivers/staging/batman-adv/proc.c | |||
@@ -30,7 +30,6 @@ | |||
30 | 30 | ||
31 | static struct proc_dir_entry *proc_batman_dir, *proc_interface_file; | 31 | static struct proc_dir_entry *proc_batman_dir, *proc_interface_file; |
32 | static struct proc_dir_entry *proc_orig_interval_file; | 32 | static struct proc_dir_entry *proc_orig_interval_file; |
33 | static struct proc_dir_entry *proc_vis_srv_file, *proc_vis_data_file; | ||
34 | 33 | ||
35 | static int proc_interfaces_read(struct seq_file *seq, void *offset) | 34 | static int proc_interfaces_read(struct seq_file *seq, void *offset) |
36 | { | 35 | { |
@@ -173,145 +172,6 @@ static int proc_orig_interval_open(struct inode *inode, struct file *file) | |||
173 | return single_open(file, proc_orig_interval_read, NULL); | 172 | return single_open(file, proc_orig_interval_read, NULL); |
174 | } | 173 | } |
175 | 174 | ||
176 | /* setting the mode of the vis server by the user */ | ||
177 | static ssize_t proc_vis_srv_write(struct file *file, const char __user * buffer, | ||
178 | size_t count, loff_t *ppos) | ||
179 | { | ||
180 | char *vis_mode_string; | ||
181 | int not_copied = 0; | ||
182 | |||
183 | vis_mode_string = kmalloc(count, GFP_KERNEL); | ||
184 | |||
185 | if (!vis_mode_string) | ||
186 | return -ENOMEM; | ||
187 | |||
188 | not_copied = copy_from_user(vis_mode_string, buffer, count); | ||
189 | vis_mode_string[count - not_copied - 1] = 0; | ||
190 | |||
191 | if ((strcmp(vis_mode_string, "client") == 0) || | ||
192 | (strcmp(vis_mode_string, "disabled") == 0)) { | ||
193 | printk(KERN_INFO "batman-adv:Setting VIS mode to client (disabling vis server)\n"); | ||
194 | atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE); | ||
195 | } else if ((strcmp(vis_mode_string, "server") == 0) || | ||
196 | (strcmp(vis_mode_string, "enabled") == 0)) { | ||
197 | printk(KERN_INFO "batman-adv:Setting VIS mode to server (enabling vis server)\n"); | ||
198 | atomic_set(&vis_mode, VIS_TYPE_SERVER_SYNC); | ||
199 | } else | ||
200 | printk(KERN_ERR "batman-adv:Unknown VIS mode: %s\n", | ||
201 | vis_mode_string); | ||
202 | |||
203 | kfree(vis_mode_string); | ||
204 | return count; | ||
205 | } | ||
206 | |||
207 | static int proc_vis_srv_read(struct seq_file *seq, void *offset) | ||
208 | { | ||
209 | int vis_server = atomic_read(&vis_mode); | ||
210 | |||
211 | seq_printf(seq, "[%c] client mode (server disabled)\n", | ||
212 | (vis_server == VIS_TYPE_CLIENT_UPDATE) ? 'x' : ' '); | ||
213 | seq_printf(seq, "[%c] server mode (server enabled)\n", | ||
214 | (vis_server == VIS_TYPE_SERVER_SYNC) ? 'x' : ' '); | ||
215 | |||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | static int proc_vis_srv_open(struct inode *inode, struct file *file) | ||
220 | { | ||
221 | return single_open(file, proc_vis_srv_read, NULL); | ||
222 | } | ||
223 | |||
224 | static int proc_vis_data_read(struct seq_file *seq, void *offset) | ||
225 | { | ||
226 | HASHIT(hashit); | ||
227 | struct vis_info *info; | ||
228 | struct vis_info_entry *entries; | ||
229 | HLIST_HEAD(vis_if_list); | ||
230 | struct if_list_entry *entry; | ||
231 | struct hlist_node *pos, *n; | ||
232 | int i; | ||
233 | char tmp_addr_str[ETH_STR_LEN]; | ||
234 | unsigned long flags; | ||
235 | int vis_server = atomic_read(&vis_mode); | ||
236 | |||
237 | rcu_read_lock(); | ||
238 | if (list_empty(&if_list) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) { | ||
239 | rcu_read_unlock(); | ||
240 | goto end; | ||
241 | } | ||
242 | |||
243 | rcu_read_unlock(); | ||
244 | |||
245 | spin_lock_irqsave(&vis_hash_lock, flags); | ||
246 | while (hash_iterate(vis_hash, &hashit)) { | ||
247 | info = hashit.bucket->data; | ||
248 | entries = (struct vis_info_entry *) | ||
249 | ((char *)info + sizeof(struct vis_info)); | ||
250 | |||
251 | for (i = 0; i < info->packet.entries; i++) { | ||
252 | if (entries[i].quality == 0) | ||
253 | continue; | ||
254 | proc_vis_insert_interface(entries[i].src, &vis_if_list, | ||
255 | compare_orig(entries[i].src, | ||
256 | info->packet.vis_orig)); | ||
257 | } | ||
258 | |||
259 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { | ||
260 | addr_to_string(tmp_addr_str, entry->addr); | ||
261 | seq_printf(seq, "%s,", tmp_addr_str); | ||
262 | |||
263 | for (i = 0; i < info->packet.entries; i++) | ||
264 | proc_vis_read_entry(seq, &entries[i], | ||
265 | entry->addr, entry->primary); | ||
266 | |||
267 | /* add primary/secondary records */ | ||
268 | if (compare_orig(entry->addr, info->packet.vis_orig)) | ||
269 | proc_vis_read_prim_sec(seq, &vis_if_list); | ||
270 | |||
271 | seq_printf(seq, "\n"); | ||
272 | } | ||
273 | |||
274 | hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) { | ||
275 | hlist_del(&entry->list); | ||
276 | kfree(entry); | ||
277 | } | ||
278 | } | ||
279 | spin_unlock_irqrestore(&vis_hash_lock, flags); | ||
280 | |||
281 | end: | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | static int proc_vis_data_open(struct inode *inode, struct file *file) | ||
286 | { | ||
287 | return single_open(file, proc_vis_data_read, NULL); | ||
288 | } | ||
289 | |||
290 | /* satisfying different prototypes ... */ | ||
291 | static ssize_t proc_dummy_write(struct file *file, const char __user *buffer, | ||
292 | size_t count, loff_t *ppos) | ||
293 | { | ||
294 | return count; | ||
295 | } | ||
296 | |||
297 | static const struct file_operations proc_vis_srv_fops = { | ||
298 | .owner = THIS_MODULE, | ||
299 | .open = proc_vis_srv_open, | ||
300 | .read = seq_read, | ||
301 | .write = proc_vis_srv_write, | ||
302 | .llseek = seq_lseek, | ||
303 | .release = single_release, | ||
304 | }; | ||
305 | |||
306 | static const struct file_operations proc_vis_data_fops = { | ||
307 | .owner = THIS_MODULE, | ||
308 | .open = proc_vis_data_open, | ||
309 | .read = seq_read, | ||
310 | .write = proc_dummy_write, | ||
311 | .llseek = seq_lseek, | ||
312 | .release = single_release, | ||
313 | }; | ||
314 | |||
315 | static const struct file_operations proc_interfaces_fops = { | 175 | static const struct file_operations proc_interfaces_fops = { |
316 | .owner = THIS_MODULE, | 176 | .owner = THIS_MODULE, |
317 | .open = proc_interfaces_open, | 177 | .open = proc_interfaces_open, |
@@ -338,12 +198,6 @@ void cleanup_procfs(void) | |||
338 | if (proc_interface_file) | 198 | if (proc_interface_file) |
339 | remove_proc_entry(PROC_FILE_INTERFACES, proc_batman_dir); | 199 | remove_proc_entry(PROC_FILE_INTERFACES, proc_batman_dir); |
340 | 200 | ||
341 | if (proc_vis_data_file) | ||
342 | remove_proc_entry(PROC_FILE_VIS_DATA, proc_batman_dir); | ||
343 | |||
344 | if (proc_vis_srv_file) | ||
345 | remove_proc_entry(PROC_FILE_VIS_SRV, proc_batman_dir); | ||
346 | |||
347 | if (proc_batman_dir) | 201 | if (proc_batman_dir) |
348 | #ifdef __NET_NET_NAMESPACE_H | 202 | #ifdef __NET_NET_NAMESPACE_H |
349 | remove_proc_entry(PROC_ROOT_DIR, init_net.proc_net); | 203 | remove_proc_entry(PROC_ROOT_DIR, init_net.proc_net); |
@@ -387,26 +241,5 @@ int setup_procfs(void) | |||
387 | return -EFAULT; | 241 | return -EFAULT; |
388 | } | 242 | } |
389 | 243 | ||
390 | proc_vis_srv_file = create_proc_entry(PROC_FILE_VIS_SRV, | ||
391 | S_IWUSR | S_IRUGO, | ||
392 | proc_batman_dir); | ||
393 | if (proc_vis_srv_file) { | ||
394 | proc_vis_srv_file->proc_fops = &proc_vis_srv_fops; | ||
395 | } else { | ||
396 | printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_SRV); | ||
397 | cleanup_procfs(); | ||
398 | return -EFAULT; | ||
399 | } | ||
400 | |||
401 | proc_vis_data_file = create_proc_entry(PROC_FILE_VIS_DATA, S_IRUGO, | ||
402 | proc_batman_dir); | ||
403 | if (proc_vis_data_file) { | ||
404 | proc_vis_data_file->proc_fops = &proc_vis_data_fops; | ||
405 | } else { | ||
406 | printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_DATA); | ||
407 | cleanup_procfs(); | ||
408 | return -EFAULT; | ||
409 | } | ||
410 | |||
411 | return 0; | 244 | return 0; |
412 | } | 245 | } |
diff --git a/drivers/staging/batman-adv/proc.h b/drivers/staging/batman-adv/proc.h index 68a255a33a8..6a972a6f26b 100644 --- a/drivers/staging/batman-adv/proc.h +++ b/drivers/staging/batman-adv/proc.h | |||
@@ -25,11 +25,6 @@ | |||
25 | #define PROC_ROOT_DIR "batman-adv" | 25 | #define PROC_ROOT_DIR "batman-adv" |
26 | #define PROC_FILE_INTERFACES "interfaces" | 26 | #define PROC_FILE_INTERFACES "interfaces" |
27 | #define PROC_FILE_ORIG_INTERVAL "orig_interval" | 27 | #define PROC_FILE_ORIG_INTERVAL "orig_interval" |
28 | #define PROC_FILE_GATEWAYS "gateways" | ||
29 | #define PROC_FILE_LOG "log" | ||
30 | #define PROC_FILE_LOG_LEVEL "log_level" | ||
31 | #define PROC_FILE_VIS_SRV "vis_server" | ||
32 | #define PROC_FILE_VIS_DATA "vis_data" | ||
33 | 28 | ||
34 | void cleanup_procfs(void); | 29 | void cleanup_procfs(void); |
35 | int setup_procfs(void); | 30 | int setup_procfs(void); |
diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index a78ae5c4dcb..8c055a124cf 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c | |||
@@ -946,6 +946,7 @@ int recv_vis_packet(struct sk_buff *skb) | |||
946 | { | 946 | { |
947 | struct vis_packet *vis_packet; | 947 | struct vis_packet *vis_packet; |
948 | struct ethhdr *ethhdr; | 948 | struct ethhdr *ethhdr; |
949 | struct bat_priv *bat_priv; | ||
949 | int hdr_size = sizeof(struct vis_packet); | 950 | int hdr_size = sizeof(struct vis_packet); |
950 | 951 | ||
951 | if (skb_headlen(skb) < hdr_size) | 952 | if (skb_headlen(skb) < hdr_size) |
@@ -965,15 +966,20 @@ int recv_vis_packet(struct sk_buff *skb) | |||
965 | if (is_my_mac(vis_packet->sender_orig)) | 966 | if (is_my_mac(vis_packet->sender_orig)) |
966 | return NET_RX_DROP; | 967 | return NET_RX_DROP; |
967 | 968 | ||
969 | /* FIXME: each batman_if will be attached to a softif */ | ||
970 | bat_priv = netdev_priv(soft_device); | ||
971 | |||
968 | switch (vis_packet->vis_type) { | 972 | switch (vis_packet->vis_type) { |
969 | case VIS_TYPE_SERVER_SYNC: | 973 | case VIS_TYPE_SERVER_SYNC: |
970 | /* TODO: handle fragmented skbs properly */ | 974 | /* TODO: handle fragmented skbs properly */ |
971 | receive_server_sync_packet(vis_packet, skb_headlen(skb)); | 975 | receive_server_sync_packet(bat_priv, vis_packet, |
976 | skb_headlen(skb)); | ||
972 | break; | 977 | break; |
973 | 978 | ||
974 | case VIS_TYPE_CLIENT_UPDATE: | 979 | case VIS_TYPE_CLIENT_UPDATE: |
975 | /* TODO: handle fragmented skbs properly */ | 980 | /* TODO: handle fragmented skbs properly */ |
976 | receive_client_update_packet(vis_packet, skb_headlen(skb)); | 981 | receive_client_update_packet(bat_priv, vis_packet, |
982 | skb_headlen(skb)); | ||
977 | break; | 983 | break; |
978 | 984 | ||
979 | default: /* ignore unknown packet */ | 985 | default: /* ignore unknown packet */ |
diff --git a/drivers/staging/batman-adv/send.c b/drivers/staging/batman-adv/send.c index 32d1756b90a..a00aa887183 100644 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c | |||
@@ -243,7 +243,7 @@ void schedule_own_packet(struct batman_if *batman_if) | |||
243 | struct bat_priv *bat_priv = netdev_priv(soft_device); | 243 | struct bat_priv *bat_priv = netdev_priv(soft_device); |
244 | unsigned long send_time; | 244 | unsigned long send_time; |
245 | struct batman_packet *batman_packet; | 245 | struct batman_packet *batman_packet; |
246 | int vis_server = atomic_read(&vis_mode); | 246 | int vis_server = atomic_read(&bat_priv->vis_mode); |
247 | 247 | ||
248 | /** | 248 | /** |
249 | * the interface gets activated here to avoid race conditions between | 249 | * the interface gets activated here to avoid race conditions between |
@@ -271,17 +271,17 @@ void schedule_own_packet(struct batman_if *batman_if) | |||
271 | if (vis_server == VIS_TYPE_SERVER_SYNC) | 271 | if (vis_server == VIS_TYPE_SERVER_SYNC) |
272 | batman_packet->flags = VIS_SERVER; | 272 | batman_packet->flags = VIS_SERVER; |
273 | else | 273 | else |
274 | batman_packet->flags = 0; | 274 | batman_packet->flags &= ~VIS_SERVER; |
275 | 275 | ||
276 | /* could be read by receive_bat_packet() */ | 276 | /* could be read by receive_bat_packet() */ |
277 | atomic_inc(&batman_if->seqno); | 277 | atomic_inc(&batman_if->seqno); |
278 | 278 | ||
279 | slide_own_bcast_window(batman_if); | 279 | slide_own_bcast_window(batman_if); |
280 | send_time = own_send_time(); | 280 | send_time = own_send_time(); |
281 | add_bat_packet_to_list(batman_if->packet_buff, | 281 | add_bat_packet_to_list(bat_priv, |
282 | batman_if->packet_buff, | ||
282 | batman_if->packet_len, | 283 | batman_if->packet_len, |
283 | batman_if, 1, send_time, | 284 | batman_if, 1, send_time); |
284 | bat_priv); | ||
285 | } | 285 | } |
286 | 286 | ||
287 | void schedule_forward_packet(struct orig_node *orig_node, | 287 | void schedule_forward_packet(struct orig_node *orig_node, |
@@ -336,10 +336,10 @@ void schedule_forward_packet(struct orig_node *orig_node, | |||
336 | batman_packet->flags &= ~DIRECTLINK; | 336 | batman_packet->flags &= ~DIRECTLINK; |
337 | 337 | ||
338 | send_time = forward_send_time(bat_priv); | 338 | send_time = forward_send_time(bat_priv); |
339 | add_bat_packet_to_list((unsigned char *)batman_packet, | 339 | add_bat_packet_to_list(bat_priv, |
340 | (unsigned char *)batman_packet, | ||
340 | sizeof(struct batman_packet) + hna_buff_len, | 341 | sizeof(struct batman_packet) + hna_buff_len, |
341 | if_incoming, 0, send_time, | 342 | if_incoming, 0, send_time); |
342 | bat_priv); | ||
343 | } | 343 | } |
344 | 344 | ||
345 | static void forw_packet_free(struct forw_packet *forw_packet) | 345 | static void forw_packet_free(struct forw_packet *forw_packet) |
diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c index 0dff959050b..829deb694b8 100644 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c | |||
@@ -182,6 +182,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) | |||
182 | struct ethhdr *ethhdr = (struct ethhdr *)skb->data; | 182 | struct ethhdr *ethhdr = (struct ethhdr *)skb->data; |
183 | struct bat_priv *priv = netdev_priv(dev); | 183 | struct bat_priv *priv = netdev_priv(dev); |
184 | struct batman_if *batman_if; | 184 | struct batman_if *batman_if; |
185 | struct bat_priv *bat_priv; | ||
185 | uint8_t dstaddr[6]; | 186 | uint8_t dstaddr[6]; |
186 | int data_len = skb->len; | 187 | int data_len = skb->len; |
187 | unsigned long flags; | 188 | unsigned long flags; |
@@ -189,6 +190,9 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) | |||
189 | if (atomic_read(&module_state) != MODULE_ACTIVE) | 190 | if (atomic_read(&module_state) != MODULE_ACTIVE) |
190 | goto dropped; | 191 | goto dropped; |
191 | 192 | ||
193 | /* FIXME: each batman_if will be attached to a softif */ | ||
194 | bat_priv = netdev_priv(soft_device); | ||
195 | |||
192 | dev->trans_start = jiffies; | 196 | dev->trans_start = jiffies; |
193 | /* TODO: check this for locks */ | 197 | /* TODO: check this for locks */ |
194 | hna_local_add(ethhdr->h_source); | 198 | hna_local_add(ethhdr->h_source); |
diff --git a/drivers/staging/batman-adv/translation-table.c b/drivers/staging/batman-adv/translation-table.c index d43b1adccf7..b735200ecf1 100644 --- a/drivers/staging/batman-adv/translation-table.c +++ b/drivers/staging/batman-adv/translation-table.c | |||
@@ -165,6 +165,19 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, | |||
165 | unsigned long flags; | 165 | unsigned long flags; |
166 | size_t hdr_len; | 166 | size_t hdr_len; |
167 | 167 | ||
168 | rcu_read_lock(); | ||
169 | if (list_empty(&if_list)) { | ||
170 | rcu_read_unlock(); | ||
171 | |||
172 | if (off == 0) | ||
173 | return sprintf(buff, | ||
174 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
175 | net_dev->name); | ||
176 | |||
177 | return 0; | ||
178 | } | ||
179 | rcu_read_unlock(); | ||
180 | |||
168 | hdr_len = sprintf(buff, | 181 | hdr_len = sprintf(buff, |
169 | "Locally retrieved addresses (from %s) announced via HNA:\n", | 182 | "Locally retrieved addresses (from %s) announced via HNA:\n", |
170 | net_dev->name); | 183 | net_dev->name); |
@@ -369,6 +382,19 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, | |||
369 | unsigned long flags; | 382 | unsigned long flags; |
370 | size_t hdr_len; | 383 | size_t hdr_len; |
371 | 384 | ||
385 | rcu_read_lock(); | ||
386 | if (list_empty(&if_list)) { | ||
387 | rcu_read_unlock(); | ||
388 | |||
389 | if (off == 0) | ||
390 | return sprintf(buff, | ||
391 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
392 | net_dev->name); | ||
393 | |||
394 | return 0; | ||
395 | } | ||
396 | rcu_read_unlock(); | ||
397 | |||
372 | hdr_len = sprintf(buff, | 398 | hdr_len = sprintf(buff, |
373 | "Globally announced HNAs received via the mesh %s (translation table):\n", | 399 | "Globally announced HNAs received via the mesh %s (translation table):\n", |
374 | net_dev->name); | 400 | net_dev->name); |
diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h index db1bb0b2204..e8d2e8c2c64 100644 --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h | |||
@@ -83,6 +83,7 @@ struct neigh_node { | |||
83 | struct bat_priv { | 83 | struct bat_priv { |
84 | struct net_device_stats stats; | 84 | struct net_device_stats stats; |
85 | atomic_t aggregation_enabled; | 85 | atomic_t aggregation_enabled; |
86 | atomic_t vis_mode; | ||
86 | struct kobject *mesh_obj; | 87 | struct kobject *mesh_obj; |
87 | }; | 88 | }; |
88 | 89 | ||
diff --git a/drivers/staging/batman-adv/vis.c b/drivers/staging/batman-adv/vis.c index 0bfc083a423..5edeb3261ac 100644 --- a/drivers/staging/batman-adv/vis.c +++ b/drivers/staging/batman-adv/vis.c | |||
@@ -102,7 +102,7 @@ static int vis_info_choose(void *data, int size) | |||
102 | 102 | ||
103 | /* insert interface to the list of interfaces of one originator, if it | 103 | /* insert interface to the list of interfaces of one originator, if it |
104 | * does not already exist in the list */ | 104 | * does not already exist in the list */ |
105 | void proc_vis_insert_interface(const uint8_t *interface, | 105 | static void vis_data_insert_interface(const uint8_t *interface, |
106 | struct hlist_head *if_list, | 106 | struct hlist_head *if_list, |
107 | bool primary) | 107 | bool primary) |
108 | { | 108 | { |
@@ -123,36 +123,119 @@ void proc_vis_insert_interface(const uint8_t *interface, | |||
123 | hlist_add_head(&entry->list, if_list); | 123 | hlist_add_head(&entry->list, if_list); |
124 | } | 124 | } |
125 | 125 | ||
126 | void proc_vis_read_prim_sec(struct seq_file *seq, | 126 | static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list) |
127 | struct hlist_head *if_list) | ||
128 | { | 127 | { |
129 | struct if_list_entry *entry; | 128 | struct if_list_entry *entry; |
130 | struct hlist_node *pos; | 129 | struct hlist_node *pos; |
131 | char tmp_addr_str[ETH_STR_LEN]; | 130 | char tmp_addr_str[ETH_STR_LEN]; |
131 | size_t len = 0; | ||
132 | 132 | ||
133 | hlist_for_each_entry(entry, pos, if_list, list) { | 133 | hlist_for_each_entry(entry, pos, if_list, list) { |
134 | if (entry->primary) | 134 | if (entry->primary) |
135 | seq_printf(seq, "PRIMARY, "); | 135 | len += sprintf(buff + len, "PRIMARY, "); |
136 | else { | 136 | else { |
137 | addr_to_string(tmp_addr_str, entry->addr); | 137 | addr_to_string(tmp_addr_str, entry->addr); |
138 | seq_printf(seq, "SEC %s, ", tmp_addr_str); | 138 | len += sprintf(buff + len, "SEC %s, ", tmp_addr_str); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | |||
142 | return len; | ||
141 | } | 143 | } |
142 | 144 | ||
143 | /* read an entry */ | 145 | /* read an entry */ |
144 | void proc_vis_read_entry(struct seq_file *seq, | 146 | static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, |
145 | struct vis_info_entry *entry, | 147 | uint8_t *src, bool primary) |
146 | uint8_t *src, | ||
147 | bool primary) | ||
148 | { | 148 | { |
149 | char to[40]; | 149 | char to[40]; |
150 | 150 | ||
151 | addr_to_string(to, entry->dest); | 151 | addr_to_string(to, entry->dest); |
152 | if (primary && entry->quality == 0) | 152 | if (primary && entry->quality == 0) |
153 | seq_printf(seq, "HNA %s, ", to); | 153 | return sprintf(buff, "HNA %s, ", to); |
154 | else if (compare_orig(entry->src, src)) | 154 | else if (compare_orig(entry->src, src)) |
155 | seq_printf(seq, "TQ %s %d, ", to, entry->quality); | 155 | return sprintf(buff, "TQ %s %d, ", to, entry->quality); |
156 | |||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, | ||
161 | size_t count, loff_t off) | ||
162 | { | ||
163 | HASHIT(hashit); | ||
164 | struct vis_info *info; | ||
165 | struct vis_info_entry *entries; | ||
166 | struct bat_priv *bat_priv = netdev_priv(net_dev); | ||
167 | HLIST_HEAD(vis_if_list); | ||
168 | struct if_list_entry *entry; | ||
169 | struct hlist_node *pos, *n; | ||
170 | size_t hdr_len, tmp_len; | ||
171 | int i, bytes_written = 0; | ||
172 | char tmp_addr_str[ETH_STR_LEN]; | ||
173 | unsigned long flags; | ||
174 | int vis_server = atomic_read(&bat_priv->vis_mode); | ||
175 | |||
176 | rcu_read_lock(); | ||
177 | if (list_empty(&if_list) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) { | ||
178 | rcu_read_unlock(); | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | rcu_read_unlock(); | ||
183 | hdr_len = 0; | ||
184 | |||
185 | spin_lock_irqsave(&vis_hash_lock, flags); | ||
186 | while (hash_iterate(vis_hash, &hashit)) { | ||
187 | info = hashit.bucket->data; | ||
188 | entries = (struct vis_info_entry *) | ||
189 | ((char *)info + sizeof(struct vis_info)); | ||
190 | |||
191 | /* estimated line length */ | ||
192 | if (count < bytes_written + 200) | ||
193 | break; | ||
194 | |||
195 | for (i = 0; i < info->packet.entries; i++) { | ||
196 | if (entries[i].quality == 0) | ||
197 | continue; | ||
198 | vis_data_insert_interface(entries[i].src, &vis_if_list, | ||
199 | compare_orig(entries[i].src, | ||
200 | info->packet.vis_orig)); | ||
201 | } | ||
202 | |||
203 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { | ||
204 | addr_to_string(tmp_addr_str, entry->addr); | ||
205 | tmp_len = sprintf(buff + bytes_written, | ||
206 | "%s,", tmp_addr_str); | ||
207 | |||
208 | for (i = 0; i < info->packet.entries; i++) | ||
209 | tmp_len += vis_data_read_entry( | ||
210 | buff + bytes_written + tmp_len, | ||
211 | &entries[i], entry->addr, | ||
212 | entry->primary); | ||
213 | |||
214 | /* add primary/secondary records */ | ||
215 | if (compare_orig(entry->addr, info->packet.vis_orig)) | ||
216 | tmp_len += vis_data_read_prim_sec( | ||
217 | buff + bytes_written + tmp_len, | ||
218 | &vis_if_list); | ||
219 | |||
220 | tmp_len += sprintf(buff + bytes_written + tmp_len, | ||
221 | "\n"); | ||
222 | |||
223 | hdr_len += tmp_len; | ||
224 | |||
225 | if (off >= hdr_len) | ||
226 | continue; | ||
227 | |||
228 | bytes_written += tmp_len; | ||
229 | } | ||
230 | |||
231 | hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) { | ||
232 | hlist_del(&entry->list); | ||
233 | kfree(entry); | ||
234 | } | ||
235 | } | ||
236 | spin_unlock_irqrestore(&vis_hash_lock, flags); | ||
237 | |||
238 | return bytes_written; | ||
156 | } | 239 | } |
157 | 240 | ||
158 | /* add the info packet to the send list, if it was not | 241 | /* add the info packet to the send list, if it was not |
@@ -280,12 +363,14 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet, | |||
280 | } | 363 | } |
281 | 364 | ||
282 | /* handle the server sync packet, forward if needed. */ | 365 | /* handle the server sync packet, forward if needed. */ |
283 | void receive_server_sync_packet(struct vis_packet *vis_packet, int vis_info_len) | 366 | void receive_server_sync_packet(struct bat_priv *bat_priv, |
367 | struct vis_packet *vis_packet, | ||
368 | int vis_info_len) | ||
284 | { | 369 | { |
285 | struct vis_info *info; | 370 | struct vis_info *info; |
286 | int is_new, make_broadcast; | 371 | int is_new, make_broadcast; |
287 | unsigned long flags; | 372 | unsigned long flags; |
288 | int vis_server = atomic_read(&vis_mode); | 373 | int vis_server = atomic_read(&bat_priv->vis_mode); |
289 | 374 | ||
290 | make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); | 375 | make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); |
291 | 376 | ||
@@ -303,13 +388,14 @@ end: | |||
303 | } | 388 | } |
304 | 389 | ||
305 | /* handle an incoming client update packet and schedule forward if needed. */ | 390 | /* handle an incoming client update packet and schedule forward if needed. */ |
306 | void receive_client_update_packet(struct vis_packet *vis_packet, | 391 | void receive_client_update_packet(struct bat_priv *bat_priv, |
392 | struct vis_packet *vis_packet, | ||
307 | int vis_info_len) | 393 | int vis_info_len) |
308 | { | 394 | { |
309 | struct vis_info *info; | 395 | struct vis_info *info; |
310 | int is_new; | 396 | int is_new; |
311 | unsigned long flags; | 397 | unsigned long flags; |
312 | int vis_server = atomic_read(&vis_mode); | 398 | int vis_server = atomic_read(&bat_priv->vis_mode); |
313 | int are_target = 0; | 399 | int are_target = 0; |
314 | 400 | ||
315 | /* clients shall not broadcast. */ | 401 | /* clients shall not broadcast. */ |
@@ -376,7 +462,7 @@ static bool vis_packet_full(struct vis_info *info) | |||
376 | 462 | ||
377 | /* generates a packet of own vis data, | 463 | /* generates a packet of own vis data, |
378 | * returns 0 on success, -1 if no packet could be generated */ | 464 | * returns 0 on success, -1 if no packet could be generated */ |
379 | static int generate_vis_packet(void) | 465 | static int generate_vis_packet(struct bat_priv *bat_priv) |
380 | { | 466 | { |
381 | HASHIT(hashit_local); | 467 | HASHIT(hashit_local); |
382 | HASHIT(hashit_global); | 468 | HASHIT(hashit_global); |
@@ -388,7 +474,7 @@ static int generate_vis_packet(void) | |||
388 | unsigned long flags; | 474 | unsigned long flags; |
389 | 475 | ||
390 | info->first_seen = jiffies; | 476 | info->first_seen = jiffies; |
391 | info->packet.vis_type = atomic_read(&vis_mode); | 477 | info->packet.vis_type = atomic_read(&bat_priv->vis_mode); |
392 | 478 | ||
393 | spin_lock_irqsave(&orig_hash_lock, flags); | 479 | spin_lock_irqsave(&orig_hash_lock, flags); |
394 | memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN); | 480 | memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN); |
@@ -568,12 +654,14 @@ static void send_vis_packets(struct work_struct *work) | |||
568 | { | 654 | { |
569 | struct vis_info *info, *temp; | 655 | struct vis_info *info, *temp; |
570 | unsigned long flags; | 656 | unsigned long flags; |
657 | /* FIXME: each batman_if will be attached to a softif */ | ||
658 | struct bat_priv *bat_priv = netdev_priv(soft_device); | ||
571 | 659 | ||
572 | spin_lock_irqsave(&vis_hash_lock, flags); | 660 | spin_lock_irqsave(&vis_hash_lock, flags); |
573 | 661 | ||
574 | purge_vis_packets(); | 662 | purge_vis_packets(); |
575 | 663 | ||
576 | if (generate_vis_packet() == 0) { | 664 | if (generate_vis_packet(bat_priv) == 0) { |
577 | /* schedule if generation was successful */ | 665 | /* schedule if generation was successful */ |
578 | send_list_add(my_vis_info); | 666 | send_list_add(my_vis_info); |
579 | } | 667 | } |
diff --git a/drivers/staging/batman-adv/vis.h b/drivers/staging/batman-adv/vis.h index 4e417fb17b9..9c1fd771cba 100644 --- a/drivers/staging/batman-adv/vis.h +++ b/drivers/staging/batman-adv/vis.h | |||
@@ -47,18 +47,13 @@ struct recvlist_node { | |||
47 | extern struct hashtable_t *vis_hash; | 47 | extern struct hashtable_t *vis_hash; |
48 | extern spinlock_t vis_hash_lock; | 48 | extern spinlock_t vis_hash_lock; |
49 | 49 | ||
50 | void proc_vis_insert_interface(const uint8_t *interface, | 50 | ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, |
51 | struct hlist_head *if_list, | 51 | size_t count, loff_t off); |
52 | bool primary); | 52 | void receive_server_sync_packet(struct bat_priv *bat_priv, |
53 | void proc_vis_read_entry(struct seq_file *seq, | 53 | struct vis_packet *vis_packet, |
54 | struct vis_info_entry *entry, | ||
55 | uint8_t *src, | ||
56 | bool primary); | ||
57 | void proc_vis_read_prim_sec(struct seq_file *seq, | ||
58 | struct hlist_head *if_list); | ||
59 | void receive_server_sync_packet(struct vis_packet *vis_packet, | ||
60 | int vis_info_len); | 54 | int vis_info_len); |
61 | void receive_client_update_packet(struct vis_packet *vis_packet, | 55 | void receive_client_update_packet(struct bat_priv *bat_priv, |
56 | struct vis_packet *vis_packet, | ||
62 | int vis_info_len); | 57 | int vis_info_len); |
63 | int vis_init(void); | 58 | int vis_init(void); |
64 | void vis_quit(void); | 59 | void vis_quit(void); |