Skip to content

Commit 70ebe4a

Browse files
Arvid Brodindavem330
authored andcommitted
net/hsr: Better variable names and update of contact info.
Signed-off-by: Arvid Brodin <arvid.brodin@alten.se> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b812540 commit 70ebe4a

File tree

8 files changed

+304
-305
lines changed

8 files changed

+304
-305
lines changed

net/hsr/hsr_device.c

Lines changed: 103 additions & 104 deletions
Large diffs are not rendered by default.

net/hsr/hsr_device.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/* Copyright 2011-2013 Autronica Fire and Security AS
1+
/* Copyright 2011-2014 Autronica Fire and Security AS
22
*
33
* This program is free software; you can redistribute it and/or modify it
44
* under the terms of the GNU General Public License as published by the Free
55
* Software Foundation; either version 2 of the License, or (at your option)
66
* any later version.
77
*
88
* Author(s):
9-
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com
9+
* 2011-2014 Arvid Brodin, arvid.brodin@alten.se
1010
*/
1111

1212
#ifndef __HSR_DEVICE_H
@@ -24,6 +24,6 @@ void hsr_set_carrier(struct net_device *hsr_dev, struct net_device *slave1,
2424
struct net_device *slave2);
2525
void hsr_check_announce(struct net_device *hsr_dev, int old_operstate);
2626
bool is_hsr_master(struct net_device *dev);
27-
int hsr_get_max_mtu(struct hsr_priv *hsr_priv);
27+
int hsr_get_max_mtu(struct hsr_priv *hsr);
2828

2929
#endif /* __HSR_DEVICE_H */

net/hsr/hsr_framereg.c

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/* Copyright 2011-2013 Autronica Fire and Security AS
1+
/* Copyright 2011-2014 Autronica Fire and Security AS
22
*
33
* This program is free software; you can redistribute it and/or modify it
44
* under the terms of the GNU General Public License as published by the Free
55
* Software Foundation; either version 2 of the License, or (at your option)
66
* any later version.
77
*
88
* Author(s):
9-
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com
9+
* 2011-2014 Arvid Brodin, arvid.brodin@alten.se
1010
*
1111
* The HSR spec says never to forward the same frame twice on the same
1212
* interface. A frame is identified by its source MAC address and its HSR
@@ -23,17 +23,17 @@
2323
#include "hsr_netlink.h"
2424

2525

26-
struct node_entry {
27-
struct list_head mac_list;
28-
unsigned char MacAddressA[ETH_ALEN];
29-
unsigned char MacAddressB[ETH_ALEN];
30-
enum hsr_dev_idx AddrB_if; /* The local slave through which AddrB
31-
* frames are received from this node
32-
*/
33-
unsigned long time_in[HSR_MAX_SLAVE];
34-
bool time_in_stale[HSR_MAX_SLAVE];
35-
u16 seq_out[HSR_MAX_DEV];
36-
struct rcu_head rcu_head;
26+
struct hsr_node {
27+
struct list_head mac_list;
28+
unsigned char MacAddressA[ETH_ALEN];
29+
unsigned char MacAddressB[ETH_ALEN];
30+
enum hsr_dev_idx AddrB_if;/* The local slave through which AddrB
31+
* frames are received from this node
32+
*/
33+
unsigned long time_in[HSR_MAX_SLAVE];
34+
bool time_in_stale[HSR_MAX_SLAVE];
35+
u16 seq_out[HSR_MAX_DEV];
36+
struct rcu_head rcu_head;
3737
};
3838

3939
/* TODO: use hash lists for mac addresses (linux/jhash.h)? */
@@ -42,10 +42,10 @@ struct node_entry {
4242

4343
/* Search for mac entry. Caller must hold rcu read lock.
4444
*/
45-
static struct node_entry *find_node_by_AddrA(struct list_head *node_db,
46-
const unsigned char addr[ETH_ALEN])
45+
static struct hsr_node *find_node_by_AddrA(struct list_head *node_db,
46+
const unsigned char addr[ETH_ALEN])
4747
{
48-
struct node_entry *node;
48+
struct hsr_node *node;
4949

5050
list_for_each_entry_rcu(node, node_db, mac_list) {
5151
if (ether_addr_equal(node->MacAddressA, addr))
@@ -58,10 +58,10 @@ static struct node_entry *find_node_by_AddrA(struct list_head *node_db,
5858

5959
/* Search for mac entry. Caller must hold rcu read lock.
6060
*/
61-
static struct node_entry *find_node_by_AddrB(struct list_head *node_db,
62-
const unsigned char addr[ETH_ALEN])
61+
static struct hsr_node *find_node_by_AddrB(struct list_head *node_db,
62+
const unsigned char addr[ETH_ALEN])
6363
{
64-
struct node_entry *node;
64+
struct hsr_node *node;
6565

6666
list_for_each_entry_rcu(node, node_db, mac_list) {
6767
if (ether_addr_equal(node->MacAddressB, addr))
@@ -74,9 +74,9 @@ static struct node_entry *find_node_by_AddrB(struct list_head *node_db,
7474

7575
/* Search for mac entry. Caller must hold rcu read lock.
7676
*/
77-
struct node_entry *hsr_find_node(struct list_head *node_db, struct sk_buff *skb)
77+
struct hsr_node *hsr_find_node(struct list_head *node_db, struct sk_buff *skb)
7878
{
79-
struct node_entry *node;
79+
struct hsr_node *node;
8080
struct ethhdr *ethhdr;
8181

8282
if (!skb_mac_header_was_set(skb))
@@ -102,7 +102,7 @@ int hsr_create_self_node(struct list_head *self_node_db,
102102
unsigned char addr_a[ETH_ALEN],
103103
unsigned char addr_b[ETH_ALEN])
104104
{
105-
struct node_entry *node, *oldnode;
105+
struct hsr_node *node, *oldnode;
106106

107107
node = kmalloc(sizeof(*node), GFP_KERNEL);
108108
if (!node)
@@ -113,7 +113,7 @@ int hsr_create_self_node(struct list_head *self_node_db,
113113

114114
rcu_read_lock();
115115
oldnode = list_first_or_null_rcu(self_node_db,
116-
struct node_entry, mac_list);
116+
struct hsr_node, mac_list);
117117
if (oldnode) {
118118
list_replace_rcu(&oldnode->mac_list, &node->mac_list);
119119
rcu_read_unlock();
@@ -154,10 +154,10 @@ int hsr_create_self_node(struct list_head *self_node_db,
154154
* We also need to detect if the sender's SlaveA and SlaveB cables have been
155155
* swapped.
156156
*/
157-
struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
158-
struct node_entry *node,
159-
struct sk_buff *skb,
160-
enum hsr_dev_idx dev_idx)
157+
struct hsr_node *hsr_merge_node(struct hsr_priv *hsr,
158+
struct hsr_node *node,
159+
struct sk_buff *skb,
160+
enum hsr_dev_idx dev_idx)
161161
{
162162
struct hsr_sup_payload *hsr_sp;
163163
struct hsr_ethhdr_sp *hsr_ethsup;
@@ -194,7 +194,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
194194
if (node)
195195
return node;
196196

197-
node = find_node_by_AddrA(&hsr_priv->node_db, hsr_sp->MacAddressA);
197+
node = find_node_by_AddrA(&hsr->node_db, hsr_sp->MacAddressA);
198198
if (node) {
199199
/* Node is known, but frame was received from an unknown
200200
* address. Node is PICS_SUBS capable; merge its AddrB.
@@ -224,7 +224,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
224224
for (i = 0; i < HSR_MAX_DEV; i++)
225225
node->seq_out[i] = ntohs(hsr_ethsup->hsr_sup.sequence_nr) - 1;
226226

227-
list_add_tail_rcu(&node->mac_list, &hsr_priv->node_db);
227+
list_add_tail_rcu(&node->mac_list, &hsr->node_db);
228228

229229
return node;
230230
}
@@ -236,10 +236,10 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
236236
* address with that node's "official" address (MacAddressA) so that upper
237237
* layers recognize where it came from.
238238
*/
239-
void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb)
239+
void hsr_addr_subst_source(struct hsr_priv *hsr, struct sk_buff *skb)
240240
{
241241
struct ethhdr *ethhdr;
242-
struct node_entry *node;
242+
struct hsr_node *node;
243243

244244
if (!skb_mac_header_was_set(skb)) {
245245
WARN_ONCE(1, "%s: Mac header not set\n", __func__);
@@ -248,7 +248,7 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb)
248248
ethhdr = (struct ethhdr *) skb_mac_header(skb);
249249

250250
rcu_read_lock();
251-
node = find_node_by_AddrB(&hsr_priv->node_db, ethhdr->h_source);
251+
node = find_node_by_AddrB(&hsr->node_db, ethhdr->h_source);
252252
if (node)
253253
ether_addr_copy(ethhdr->h_source, node->MacAddressA);
254254
rcu_read_unlock();
@@ -264,13 +264,13 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb)
264264
* This is needed to keep the packets flowing through switches that learn on
265265
* which "side" the different interfaces are.
266266
*/
267-
void hsr_addr_subst_dest(struct hsr_priv *hsr_priv, struct ethhdr *ethhdr,
267+
void hsr_addr_subst_dest(struct hsr_priv *hsr, struct ethhdr *ethhdr,
268268
enum hsr_dev_idx dev_idx)
269269
{
270-
struct node_entry *node;
270+
struct hsr_node *node;
271271

272272
rcu_read_lock();
273-
node = find_node_by_AddrA(&hsr_priv->node_db, ethhdr->h_dest);
273+
node = find_node_by_AddrA(&hsr->node_db, ethhdr->h_dest);
274274
if (node && (node->AddrB_if == dev_idx))
275275
ether_addr_copy(ethhdr->h_dest, node->MacAddressB);
276276
rcu_read_unlock();
@@ -295,7 +295,7 @@ static bool seq_nr_after(u16 a, u16 b)
295295
#define seq_nr_before_or_eq(a, b) (!seq_nr_after((a), (b)))
296296

297297

298-
void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx)
298+
void hsr_register_frame_in(struct hsr_node *node, enum hsr_dev_idx dev_idx)
299299
{
300300
if ((dev_idx < 0) || (dev_idx >= HSR_MAX_SLAVE)) {
301301
WARN_ONCE(1, "%s: Invalid dev_idx (%d)\n", __func__, dev_idx);
@@ -314,7 +314,7 @@ void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx)
314314
* 0 otherwise, or
315315
* negative error code on error
316316
*/
317-
int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx,
317+
int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx,
318318
struct sk_buff *skb)
319319
{
320320
struct hsr_ethhdr *hsr_ethhdr;
@@ -340,7 +340,7 @@ int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx,
340340

341341

342342

343-
static bool is_late(struct node_entry *node, enum hsr_dev_idx dev_idx)
343+
static bool is_late(struct hsr_node *node, enum hsr_dev_idx dev_idx)
344344
{
345345
enum hsr_dev_idx other;
346346

@@ -366,14 +366,14 @@ static bool is_late(struct node_entry *node, enum hsr_dev_idx dev_idx)
366366
/* Remove stale sequence_nr records. Called by timer every
367367
* HSR_LIFE_CHECK_INTERVAL (two seconds or so).
368368
*/
369-
void hsr_prune_nodes(struct hsr_priv *hsr_priv)
369+
void hsr_prune_nodes(struct hsr_priv *hsr)
370370
{
371-
struct node_entry *node;
371+
struct hsr_node *node;
372372
unsigned long timestamp;
373373
unsigned long time_a, time_b;
374374

375375
rcu_read_lock();
376-
list_for_each_entry_rcu(node, &hsr_priv->node_db, mac_list) {
376+
list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
377377
/* Shorthand */
378378
time_a = node->time_in[HSR_DEV_SLAVE_A];
379379
time_b = node->time_in[HSR_DEV_SLAVE_B];
@@ -399,17 +399,17 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
399399
msecs_to_jiffies(1.5*MAX_SLAVE_DIFF))) {
400400

401401
if (is_late(node, HSR_DEV_SLAVE_A))
402-
hsr_nl_ringerror(hsr_priv, node->MacAddressA,
402+
hsr_nl_ringerror(hsr, node->MacAddressA,
403403
HSR_DEV_SLAVE_A);
404404
else if (is_late(node, HSR_DEV_SLAVE_B))
405-
hsr_nl_ringerror(hsr_priv, node->MacAddressA,
405+
hsr_nl_ringerror(hsr, node->MacAddressA,
406406
HSR_DEV_SLAVE_B);
407407
}
408408

409409
/* Prune old entries */
410410
if (time_is_before_jiffies(timestamp +
411411
msecs_to_jiffies(HSR_NODE_FORGET_TIME))) {
412-
hsr_nl_nodedown(hsr_priv, node->MacAddressA);
412+
hsr_nl_nodedown(hsr, node->MacAddressA);
413413
list_del_rcu(&node->mac_list);
414414
/* Note that we need to free this entry later: */
415415
kfree_rcu(node, rcu_head);
@@ -419,21 +419,21 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
419419
}
420420

421421

422-
void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos,
422+
void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
423423
unsigned char addr[ETH_ALEN])
424424
{
425-
struct node_entry *node;
425+
struct hsr_node *node;
426426

427427
if (!_pos) {
428-
node = list_first_or_null_rcu(&hsr_priv->node_db,
429-
struct node_entry, mac_list);
428+
node = list_first_or_null_rcu(&hsr->node_db,
429+
struct hsr_node, mac_list);
430430
if (node)
431431
ether_addr_copy(addr, node->MacAddressA);
432432
return node;
433433
}
434434

435435
node = _pos;
436-
list_for_each_entry_continue_rcu(node, &hsr_priv->node_db, mac_list) {
436+
list_for_each_entry_continue_rcu(node, &hsr->node_db, mac_list) {
437437
ether_addr_copy(addr, node->MacAddressA);
438438
return node;
439439
}
@@ -442,7 +442,7 @@ void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos,
442442
}
443443

444444

445-
int hsr_get_node_data(struct hsr_priv *hsr_priv,
445+
int hsr_get_node_data(struct hsr_priv *hsr,
446446
const unsigned char *addr,
447447
unsigned char addr_b[ETH_ALEN],
448448
unsigned int *addr_b_ifindex,
@@ -451,12 +451,12 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv,
451451
int *if2_age,
452452
u16 *if2_seq)
453453
{
454-
struct node_entry *node;
454+
struct hsr_node *node;
455455
unsigned long tdiff;
456456

457457

458458
rcu_read_lock();
459-
node = find_node_by_AddrA(&hsr_priv->node_db, addr);
459+
node = find_node_by_AddrA(&hsr->node_db, addr);
460460
if (!node) {
461461
rcu_read_unlock();
462462
return -ENOENT; /* No such entry */
@@ -488,8 +488,8 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv,
488488
*if1_seq = node->seq_out[HSR_DEV_SLAVE_B];
489489
*if2_seq = node->seq_out[HSR_DEV_SLAVE_A];
490490

491-
if ((node->AddrB_if != HSR_DEV_NONE) && hsr_priv->slave[node->AddrB_if])
492-
*addr_b_ifindex = hsr_priv->slave[node->AddrB_if]->ifindex;
491+
if ((node->AddrB_if != HSR_DEV_NONE) && hsr->slave[node->AddrB_if])
492+
*addr_b_ifindex = hsr->slave[node->AddrB_if]->ifindex;
493493
else
494494
*addr_b_ifindex = -1;
495495

net/hsr/hsr_framereg.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
/* Copyright 2011-2013 Autronica Fire and Security AS
1+
/* Copyright 2011-2014 Autronica Fire and Security AS
22
*
33
* This program is free software; you can redistribute it and/or modify it
44
* under the terms of the GNU General Public License as published by the Free
55
* Software Foundation; either version 2 of the License, or (at your option)
66
* any later version.
77
*
88
* Author(s):
9-
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com
9+
* 2011-2014 Arvid Brodin, arvid.brodin@alten.se
1010
*/
1111

12-
#ifndef _HSR_FRAMEREG_H
13-
#define _HSR_FRAMEREG_H
12+
#ifndef __HSR_FRAMEREG_H
13+
#define __HSR_FRAMEREG_H
1414

1515
#include "hsr_main.h"
1616

17-
struct node_entry;
17+
struct hsr_node;
1818

19-
struct node_entry *hsr_find_node(struct list_head *node_db, struct sk_buff *skb);
19+
struct hsr_node *hsr_find_node(struct list_head *node_db, struct sk_buff *skb);
2020

21-
struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
22-
struct node_entry *node,
23-
struct sk_buff *skb,
24-
enum hsr_dev_idx dev_idx);
21+
struct hsr_node *hsr_merge_node(struct hsr_priv *hsr,
22+
struct hsr_node *node,
23+
struct sk_buff *skb,
24+
enum hsr_dev_idx dev_idx);
2525

26-
void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb);
27-
void hsr_addr_subst_dest(struct hsr_priv *hsr_priv, struct ethhdr *ethhdr,
26+
void hsr_addr_subst_source(struct hsr_priv *hsr, struct sk_buff *skb);
27+
void hsr_addr_subst_dest(struct hsr_priv *hsr, struct ethhdr *ethhdr,
2828
enum hsr_dev_idx dev_idx);
2929

30-
void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx);
30+
void hsr_register_frame_in(struct hsr_node *node, enum hsr_dev_idx dev_idx);
3131

32-
int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx,
32+
int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx,
3333
struct sk_buff *skb);
3434

35-
void hsr_prune_nodes(struct hsr_priv *hsr_priv);
35+
void hsr_prune_nodes(struct hsr_priv *hsr);
3636

3737
int hsr_create_self_node(struct list_head *self_node_db,
3838
unsigned char addr_a[ETH_ALEN],
3939
unsigned char addr_b[ETH_ALEN]);
4040

41-
void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos,
41+
void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
4242
unsigned char addr[ETH_ALEN]);
4343

44-
int hsr_get_node_data(struct hsr_priv *hsr_priv,
44+
int hsr_get_node_data(struct hsr_priv *hsr,
4545
const unsigned char *addr,
4646
unsigned char addr_b[ETH_ALEN],
4747
unsigned int *addr_b_ifindex,
@@ -50,4 +50,4 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv,
5050
int *if2_age,
5151
u16 *if2_seq);
5252

53-
#endif /* _HSR_FRAMEREG_H */
53+
#endif /* __HSR_FRAMEREG_H */

0 commit comments

Comments
 (0)