pull request: batman-adv 20160504
Subsystems (3)
Hello David,
this is a pull request intended for net-next.
In this batch you don't have any patch that depends on our fixes, therefore you can safely merge it even if the net tree has not been merged yet.
In this patchset you basically have some cleanup work, code refactoring, style fixes and two updates for the MAINTAINERS file.
Please pull or let me know of any problem!
Thanks a lot,
Antonio
The following changes since commit e03179fe78d5b39dbf3e8b0b50f7c406514b15c7:
net: ethernet: fec_mpc52xx: move to new ethtool api {get|set}_link_ksettings (2016-05-03 13:03:53 -0400)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batman-adv-for-davem
for you to fetch changes up to 64ae74455371a40bc9f9c8325eb4c37f2978c95f:
batman-adv: Split batadv_iv_ogm_orig_del_if function (2016-05-04 02:22:03 +0800)
----------------------------------------------------------------
In this pull request you have:
- two changes to the MAINTAINERS file where one marks our mailing list as moderated and the other adds a missing documentation file
- kernel-doc fixes
- code refactoring and various cleanups
----------------------------------------------------------------
Antonio Quartulli (2):
batman-adv: use static string for table headers
batman-adv: fix wrong names in kerneldoc
Geliang Tang (2):
batman-adv: use list_for_each_entry_safe
batman-adv: use to_delayed_work
Simon Wunderlich (4):
batman-adv: Start new development cycle
batman-adv: fix debuginfo macro style issue
batman-adv: move and restructure batadv_v_ogm_forward
batman-adv: Merge batadv_v_ogm_orig_update into batadv_v_ogm_route_update
Sven Eckelmann (7):
MAINTAINERS: Mark BATMAN ADVANCED mailing list as moderated
MAINTAINERS: Add BATMAN ADVANCED documentation files
batman-adv: Fix checkpatch warning about 'unsigned' type
batman-adv: Fix kerneldoc for batadv_compare_claim
batman-adv: Add kernel-doc for batadv_interface_rx
batman-adv: Fix function names on new line starting with '*'
batman-adv: Split batadv_iv_ogm_orig_del_if function
MAINTAINERS | 5 +- net/batman-adv/bat_iv_ogm.c | 123 +++++++++++++------- net/batman-adv/bat_v.c | 9 +- net/batman-adv/bat_v_ogm.c | 205 ++++++++++++++++----------------- net/batman-adv/bridge_loop_avoidance.c | 19 ++- net/batman-adv/debugfs.c | 19 +-- net/batman-adv/distributed-arp-table.c | 8 +- net/batman-adv/fragmentation.c | 12 +- net/batman-adv/icmp_socket.c | 24 ++-- net/batman-adv/main.c | 8 +- net/batman-adv/main.h | 5 +- net/batman-adv/multicast.c | 11 +- net/batman-adv/network-coding.c | 20 ++-- net/batman-adv/originator.c | 4 +- net/batman-adv/packet.h | 2 +- net/batman-adv/send.c | 4 +- net/batman-adv/soft-interface.c | 20 +++- net/batman-adv/translation-table.c | 11 +- 18 files changed, 277 insertions(+), 232 deletions(-)
PATCH 1/15 MAINTAINERS: Mark BATMAN ADVANCED mailing list as moderated
From: Sven Eckelmann <[email protected]>
The mailing list of [email protected] is moderated for non-subscribers and non-whitelisted addresses. Such mails will be delayed but the sender will not be informed about the moderation.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -2203,7 +2203,7 @@ BATMAN ADVANCED M: Marek Lindner <[email protected]> M: Simon Wunderlich <[email protected]> M: Antonio Quartulli <[email protected]> -L: [email protected] +L: [email protected] (moderated for non-subscribers) W: https://www.open-mesh.org/ Q: https://patchwork.open-mesh.org/project/batman/list/ S: Maintained
Signature · 1 line
2.8.2
PATCH 2/15 MAINTAINERS: Add BATMAN ADVANCED documentation files
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
The sysfs ABI documentation files and the batman-adv.txt are maintained by the BATMAN ADVANCED maintainers and patches for them should therefore be sent to them.
--- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
@@ -2207,6 +2207,9 @@ L: [email protected] (moderated for non-subscribers) W: https://www.open-mesh.org/ Q: https://patchwork.open-mesh.org/project/batman/list/ S: Maintained +F: Documentation/ABI/testing/sysfs-class-net-batman-adv +F: Documentation/ABI/testing/sysfs-class-net-mesh +F: Documentation/networking/batman-adv.txt F: net/batman-adv/ BAYCOM/HDLCDRV DRIVERS FOR AX.25
Signature · 1 line
2.8.2
PATCH 2/15 MAINTAINERS: Add BATMAN ADVANCED documentation files
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
The sysfs ABI documentation files and the batman-adv.txt are maintained by the BATMAN ADVANCED maintainers and patches for them should therefore be sent to them.
--- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
@@ -2207,6 +2207,9 @@ L: [email protected] (moderated for non-subscribers) W: https://www.open-mesh.org/ Q: https://patchwork.open-mesh.org/project/batman/list/ S: Maintained +F: Documentation/ABI/testing/sysfs-class-net-batman-adv +F: Documentation/ABI/testing/sysfs-class-net-mesh +F: Documentation/networking/batman-adv.txt F: net/batman-adv/ BAYCOM/HDLCDRV DRIVERS FOR AX.25
Signature · 1 line
2.8.2
PATCH 3/15 batman-adv: Start new development cycle
In reply to Antonio QuartulliFrom: Simon Wunderlich <[email protected]>
--- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.h +1 -1
@@ -24,7 +24,7 @@#define BATADV_DRIVER_DEVICE "batman-adv"#ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2016.1" +#define BATADV_SOURCE_VERSION "2016.2"#endif /* B.A.T.M.A.N. parameters */
Signature · 1 line
2.8.2
PATCH 4/15 batman-adv: use static string for table headers
In reply to Antonio QuartulliUse a static string when showing table headers rather then a nonsense parametric one with fixed arguments.
It is easier to grep and it does not need to be recomputed at runtime each time.
--- net/batman-adv/bat_iv_ogm.c | 8 +++----- net/batman-adv/bat_v.c | 9 ++++----- net/batman-adv/bridge_loop_avoidance.c | 7 +++---- net/batman-adv/distributed-arp-table.c | 4 ++-- net/batman-adv/translation-table.c | 9 ++++----- 5 files changed, 16 insertions(+), 21 deletions(-)
net/batman-adv/bat_iv_ogm.c +3 -5
@@ -1829,9 +1829,8 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,int batman_count =0 ;u32 i; -seq_printf (seq," %-15s %s (%s/%i) %17s [%10s]: %20s ...\n" , -"Originator" ,"last-seen" ,"#" ,BATADV_TQ_MAX_VALUE , -"Nexthop" ,"outgoingIF" ,"Potential nexthops" ); +seq_puts (seq, +" Originator last-seen (#/255) Nexthop [outgoingIF]: Potential nexthops ...\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -1911,8 +1910,7 @@ static void batadv_iv_neigh_print(struct batadv_priv *bat_priv,struct batadv_hard_iface *hard_iface;int batman_count =0 ; -seq_printf (seq," %10s %-13s %s\n" , -"IF" ,"Neighbor" ,"last-seen" ); +seq_puts (seq," IF Neighbor last-seen\n" );rcu_read_lock ();list_for_each_entry_rcu (hard_iface, &batadv_hardif_list, list) {
net/batman-adv/bat_v.c +4 -5
@@ -151,8 +151,8 @@ static void batadv_v_neigh_print(struct batadv_priv *bat_priv,struct batadv_hard_iface *hard_iface;int batman_count =0 ; -seq_printf (seq," %-15s %s (%11s) [%10s]\n" ,"Neighbor" , -"last-seen" ,"throughput" ,"IF" ); +seq_puts (seq, +" Neighbor last-seen ( throughput) [ IF]\n" );rcu_read_lock ();list_for_each_entry_rcu (hard_iface, &batadv_hardif_list, list) {
@@ -191,9 +191,8 @@ static void batadv_v_orig_print(struct batadv_priv *bat_priv,int batman_count =0 ;u32 i; -seq_printf (seq," %-15s %s (%11s) %17s [%10s]: %20s ...\n" , -"Originator" ,"last-seen" ,"throughput" ,"Nexthop" , -"outgoingIF" ,"Potential nexthops" ); +seq_puts (seq, +" Originator last-seen ( throughput) Nexthop [outgoingIF]: Potential nexthops ...\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
net/batman-adv/bridge_loop_avoidance.c +3 -4
@@ -1815,8 +1815,8 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)"Claims announced for the mesh %s (orig %pM, group id %#.4x)\n" , net_dev->name, primary_addr, ntohs(bat_priv->bla.claim_dest.group)); -seq_printf (seq," %-17s %-5s %-17s [o] (%-6s)\n" , -"Client" ,"VID" ,"Originator" ,"CRC" ); +seq_puts (seq, +" Client VID Originator [o] (CRC )\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -1873,8 +1873,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)"Backbones announced for the mesh %s (orig %pM, group id %#.4x)\n" , net_dev->name, primary_addr, ntohs(bat_priv->bla.claim_dest.group)); -seq_printf (seq," %-17s %-5s %-9s (%-6s)\n" , -"Originator" ,"VID" ,"last seen" ,"CRC" ); +seq_puts (seq," Originator VID last seen (CRC )\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
net/batman-adv/distributed-arp-table.c +2 -2
@@ -814,8 +814,8 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) goto out;seq_printf (seq,"Distributed ARP Table (%s):\n" , net_dev->name); -seq_printf (seq," %-7s %-9s %4s %11s\n" ,"IPv4" , -"MAC" ,"VID" ,"last-seen" ); +seq_puts (seq, +" IPv4 MAC VID last-seen\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
net/batman-adv/translation-table.c +4 -5
@@ -1008,8 +1008,8 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)seq_printf (seq,"Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n" , net_dev->name, (u8 )atomic_read (&bat_priv->tt.vn)); -seq_printf (seq," %-13s %s %-8s %-9s (%-10s)\n" ,"Client" ,"VID" , -"Flags" ,"Last seen" ,"CRC" ); +seq_puts (seq, +" Client VID Flags Last seen (CRC )\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -1706,9 +1706,8 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)seq_printf (seq,"Globally announced TT entries received via the mesh %s\n" , net_dev->name); -seq_printf (seq," %-13s %s %s %-15s %s (%-10s) %s\n" , -"Client" ,"VID" ,"(TTVN)" ,"Originator" ,"(Curr TTVN)" , -"CRC" ,"Flags" ); +seq_puts (seq, +" Client VID (TTVN) Originator (Curr TTVN) (CRC ) Flags\n" );for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
Signature · 1 line
2.8.2
PATCH 5/15 batman-adv: use list_for_each_entry_safe
In reply to Antonio QuartulliFrom: Geliang Tang <[email protected]>
Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code.
--- net/batman-adv/icmp_socket.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
net/batman-adv/icmp_socket.c +9 -13
@@ -104,25 +104,21 @@ static int batadv_socket_open(struct inode *inode, struct file *file)static int batadv_socket_release (struct inode *inode,struct file *file) { -struct batadv_socket_client *socket_client = file->private_data; -struct batadv_socket_packet *socket_packet; -struct list_head *list_pos, *list_pos_tmp; +struct batadv_socket_client *client = file->private_data; +struct batadv_socket_packet *packet, *tmp; -spin_lock_bh (&socket_client->lock); +spin_lock_bh (&client->lock);/* for all packets in the queue ... */ -list_for_each_safe (list_pos, list_pos_tmp, &socket_client->queue_list) { - socket_packet =list_entry (list_pos, - struct batadv_socket_packet, list); - -list_del (list_pos); -kfree (socket_packet); +list_for_each_entry_safe (packet, tmp, &client->queue_list, list) { +list_del (&packet->list); +kfree (packet); } - batadv_socket_client_hash[socket_client->index] =NULL ; -spin_unlock_bh (&socket_client->lock); + batadv_socket_client_hash[client->index] =NULL ; +spin_unlock_bh (&client->lock); -kfree (socket_client); +kfree (client);module_put (THIS_MODULE );return 0 ;
Signature · 1 line
2.8.2
PATCH 6/15 batman-adv: use to_delayed_work
In reply to Antonio QuartulliFrom: Geliang Tang <[email protected]>
Use to_delayed_work() instead of open-coding it.
--- net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/network-coding.c | 2 +- net/batman-adv/originator.c | 2 +- net/batman-adv/send.c | 4 ++-- net/batman-adv/translation-table.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +1 -1
@@ -1303,7 +1303,7 @@ static void batadv_bla_periodic_work(struct work_struct *work)struct batadv_hard_iface *primary_if;int i; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); priv_bla = container_of(delayed_work, struct batadv_priv_bla, work); bat_priv = container_of(priv_bla, struct batadv_priv, bla); primary_if =batadv_primary_if_get_selected (bat_priv);
net/batman-adv/distributed-arp-table.c +1 -1
@@ -152,7 +152,7 @@ static void batadv_dat_purge(struct work_struct *work)struct batadv_priv_dat *priv_dat;struct batadv_priv *bat_priv; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); priv_dat = container_of(delayed_work, struct batadv_priv_dat, work); bat_priv = container_of(priv_dat, struct batadv_priv, dat);
net/batman-adv/network-coding.c +1 -1
@@ -714,7 +714,7 @@ static void batadv_nc_worker(struct work_struct *work)struct batadv_priv *bat_priv;unsigned long timeout; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); priv_nc = container_of(delayed_work, struct batadv_priv_nc, work); bat_priv = container_of(priv_nc, struct batadv_priv, nc);
net/batman-adv/originator.c +1 -1
@@ -1222,7 +1222,7 @@ static void batadv_purge_orig(struct work_struct *work)struct delayed_work *delayed_work;struct batadv_priv *bat_priv; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);_batadv_purge_orig (bat_priv); queue_delayed_work(batadv_event_workqueue,
net/batman-adv/send.c +2 -2
@@ -552,7 +552,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)struct net_device *soft_iface;struct batadv_priv *bat_priv; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); forw_packet = container_of(delayed_work, struct batadv_forw_packet, delayed_work); soft_iface = forw_packet->if_incoming->soft_iface;
@@ -604,7 +604,7 @@ void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work)struct batadv_forw_packet *forw_packet;struct batadv_priv *bat_priv; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); forw_packet = container_of(delayed_work, struct batadv_forw_packet, delayed_work); bat_priv =netdev_priv (forw_packet->if_incoming->soft_iface);
net/batman-adv/translation-table.c +1 -1
@@ -3226,7 +3226,7 @@ static void batadv_tt_purge(struct work_struct *work)struct batadv_priv_tt *priv_tt;struct batadv_priv *bat_priv; - delayed_work = container_of(work, struct delayed_work, work); + delayed_work =to_delayed_work (work); priv_tt = container_of(delayed_work, struct batadv_priv_tt, work); bat_priv = container_of(priv_tt, struct batadv_priv, tt);
Signature · 1 line
2.8.2
PATCH 7/15 batman-adv: fix wrong names in kerneldoc
In reply to Antonio Quartulli--- net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/icmp_socket.c | 2 +- net/batman-adv/main.h | 3 ++- net/batman-adv/multicast.c | 11 ++++++----- net/batman-adv/originator.c | 2 +- net/batman-adv/packet.h | 2 +- net/batman-adv/soft-interface.c | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +1 -1
@@ -1575,7 +1575,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb, }/** -* batadv_bla_init - free all bla structures +* batadv_bla_free - free all bla structures * @bat_priv: the bat priv with all the soft interface information * * for softinterface free or module unload
net/batman-adv/distributed-arp-table.c +1 -1
@@ -717,7 +717,7 @@ void batadv_dat_status_update(struct net_device *net_dev) }/** -* batadv_gw_tvlv_ogm_handler_v1 - process incoming dat tvlv container +* batadv_dat_tvlv_ogm_handler_v1 - process incoming dat tvlv container * @bat_priv: the bat priv with all the soft interface information * @orig: the orig_node of the ogm * @flags: flags indicating the tvlv state (see batadv_tvlv_handler_flags)
net/batman-adv/icmp_socket.c +1 -1
@@ -333,7 +333,7 @@ err: }/** -* batadv_socket_receive_packet - schedule an icmp packet to be sent to +* batadv_socket_add_packet - schedule an icmp packet to be sent to * userspace on an icmp socket. * @socket_client: the socket this packet belongs to * @icmph: pointer to the header of the icmp packet
net/batman-adv/main.h +2 -1
@@ -296,7 +296,8 @@ static inline bool batadv_compare_eth(const void *data1, const void *data2) }/** -* has_timed_out - compares current time (jiffies) and timestamp + timeout +* batadv_has_timed_out - compares current time (jiffies) and timestamp + +* timeout * @timestamp: base value to compare with (in jiffies) * @timeout: added to base value before comparing (in milliseconds) *
net/batman-adv/multicast.c +6 -5
@@ -394,7 +394,8 @@ static int batadv_mcast_forw_mode_check(struct batadv_priv *bat_priv, }/** -* batadv_mcast_want_all_ip_count - count nodes with unspecific mcast interest +* batadv_mcast_forw_want_all_ip_count - count nodes with unspecific mcast +* interest * @bat_priv: the bat priv with all the soft interface information * @ethhdr: ethernet header of a packet *
@@ -433,7 +434,7 @@ batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv, }/** -* batadv_mcast_want_forw_ipv4_node_get - get a node with an ipv4 flag +* batadv_mcast_forw_ipv4_node_get - get a node with an ipv4 flag * @bat_priv: the bat priv with all the soft interface information * * Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set and
@@ -460,7 +461,7 @@ batadv_mcast_forw_ipv4_node_get(struct batadv_priv *bat_priv) }/** -* batadv_mcast_want_forw_ipv6_node_get - get a node with an ipv6 flag +* batadv_mcast_forw_ipv6_node_get - get a node with an ipv6 flag * @bat_priv: the bat priv with all the soft interface information * * Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set
@@ -487,7 +488,7 @@ batadv_mcast_forw_ipv6_node_get(struct batadv_priv *bat_priv) }/** -* batadv_mcast_want_forw_ip_node_get - get a node with an ipv4/ipv6 flag +* batadv_mcast_forw_ip_node_get - get a node with an ipv4/ipv6 flag * @bat_priv: the bat priv with all the soft interface information * @ethhdr: an ethernet header to determine the protocol family from *
@@ -511,7 +512,7 @@ batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv, }/** -* batadv_mcast_want_forw_unsnoop_node_get - get a node with an unsnoopable flag +* batadv_mcast_forw_unsnoop_node_get - get a node with an unsnoopable flag * @bat_priv: the bat priv with all the soft interface information * * Return: an orig_node which has the BATADV_MCAST_WANT_ALL_UNSNOOPABLES flag
net/batman-adv/originator.c +1 -1
@@ -289,7 +289,7 @@ void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node) }/** -* batadv_orig_node_get_router - router to the originator depending on iface +* batadv_orig_router_get - router to the originator depending on iface * @orig_node: the orig node for the router * @if_outgoing: the interface where the payload packet has been received or * the OGM should be sent to
net/batman-adv/packet.h +1 -1
@@ -501,7 +501,7 @@ struct batadv_coded_packet {#pragma pack()/** -* struct batadv_unicast_tvlv - generic unicast packet with tvlv payload +* struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload * @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the genereal header * @ttl: time to live for this packet, part of the genereal header
net/batman-adv/soft-interface.c +1 -1
@@ -539,7 +539,7 @@ struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv, }/** -* batadv_create_vlan - allocate the needed resources for a new vlan +* batadv_softif_create_vlan - allocate the needed resources for a new vlan * @bat_priv: the bat priv with all the soft interface information * @vid: the VLAN identifier *
Signature · 1 line
2.8.2
PATCH 8/15 batman-adv: Fix checkpatch warning about 'unsigned' type
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
checkpatch.pl warns about the use of 'unsigned' as a short form for 'unsigned int'.
--- net/batman-adv/fragmentation.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/batman-adv/fragmentation.c +6 -6
@@ -407,8 +407,8 @@ static struct sk_buff *batadv_frag_create(struct sk_buff *skb, unsigned int mtu) {struct sk_buff *skb_fragment; -unsigned header_size =sizeof (*frag_head); -unsigned fragment_size = mtu - header_size; +unsigned int header_size =sizeof (*frag_head); +unsigned int fragment_size = mtu - header_size; skb_fragment =netdev_alloc_skb (NULL , mtu +ETH_HLEN );if (!skb_fragment)
@@ -444,15 +444,15 @@ bool batadv_frag_send_packet(struct sk_buff *skb,struct batadv_hard_iface *primary_if =NULL ;struct batadv_frag_packet frag_header;struct sk_buff *skb_fragment; -unsigned mtu = neigh_node->if_incoming->net_dev->mtu; -unsigned header_size =sizeof (frag_header); -unsigned max_fragment_size, max_packet_size; +unsigned int mtu = neigh_node->if_incoming->net_dev->mtu; +unsigned int header_size =sizeof (frag_header); +unsigned int max_fragment_size, max_packet_size;bool ret = false;/* To avoid merge and refragmentation at next-hops we never send * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE */ - mtu =min_t (unsigned, mtu,BATADV_FRAG_MAX_FRAG_SIZE ); + mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE); max_fragment_size = mtu - header_size; max_packet_size = max_fragment_size *BATADV_FRAG_MAX_FRAGMENTS ;
Signature · 1 line
2.8.2
PATCH 9/15 batman-adv: Fix kerneldoc for batadv_compare_claim
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
--- net/batman-adv/bridge_loop_avoidance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/bridge_loop_avoidance.c +1 -1
@@ -120,7 +120,7 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node, }/** -* batadv_compare_backbone_gw - compare address and vid of two claims +* batadv_compare_claim - compare address and vid of two claims * @node: list node of the first entry to compare * @data2: pointer to the second claims *
Signature · 1 line
2.8.2
PATCH 10/15 batman-adv: Add kernel-doc for batadv_interface_rx
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
--- net/batman-adv/soft-interface.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
net/batman-adv/soft-interface.c +18 -0
@@ -381,6 +381,24 @@ end:return NETDEV_TX_OK ; } +/** +* batadv_interface_rx - receive ethernet frame on local batman-adv interface +* @soft_iface: local interface which will receive the ethernet frame +* @skb: ethernet frame for @soft_iface +* @recv_if: interface on which the batman-adv packet was received +* @hdr_size: size of already parsed batman-adv header +* @orig_node: originator from which the batman-adv packet was sent +* +* Sends a ethernet frame to the receive path of the local @soft_iface. +* skb->data has still point to the batman-adv header with the size @hdr_size. +* The caller has to have parsed this header already and made sure that at least +* @hdr_size bytes are still available for pull in @skb. +* +* The packet may still get dropped. This can happen when the encapsulated +* ethernet frame is invalid or contains again an batman-adv packet. Also +* unicast packets will be dropped directly when it was sent between two +* isolated clients. +*/ void batadv_interface_rx (struct net_device *soft_iface,struct sk_buff *skb,struct batadv_hard_iface *recv_if,int hdr_size,struct batadv_orig_node *orig_node)
Signature · 1 line
2.8.2
PATCH 11/15 batman-adv: Fix function names on new line starting with '*'
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
Some really long function names in batman-adv require a newline between return type and the function name. This has lead to some lines starting with *batadv_...
This * belongs to the return type and thus should be on the same line as the return type.
--- net/batman-adv/bridge_loop_avoidance.c | 6 +++--- net/batman-adv/main.c | 8 ++++---- net/batman-adv/network-coding.c | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +3 -3
@@ -200,9 +200,9 @@ static void batadv_claim_put(struct batadv_bla_claim *claim)* * Return: claim if found or NULL otherwise. */ -static struct batadv_bla_claim -*batadv_claim_hash_find (struct batadv_priv *bat_priv, -struct batadv_bla_claim *data) +static struct batadv_bla_claim * +batadv_claim_hash_find (struct batadv_priv *bat_priv, +struct batadv_bla_claim *data) {struct batadv_hashtable *hash = bat_priv->bla.claim_hash;struct hlist_head *head;
net/batman-adv/main.c +4 -4
@@ -663,8 +663,8 @@ static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)* * Return: tvlv handler if found or NULL otherwise. */ -static struct batadv_tvlv_handler -*batadv_tvlv_handler_get (struct batadv_priv *bat_priv,u8 type,u8 version) +static struct batadv_tvlv_handler * +batadv_tvlv_handler_get (struct batadv_priv *bat_priv,u8 type,u8 version) {struct batadv_tvlv_handler *tvlv_handler_tmp, *tvlv_handler =NULL ;
@@ -722,8 +722,8 @@ static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)* * Return: tvlv container if found or NULL otherwise. */ -static struct batadv_tvlv_container -*batadv_tvlv_container_get (struct batadv_priv *bat_priv,u8 type,u8 version) +static struct batadv_tvlv_container * +batadv_tvlv_container_get (struct batadv_priv *bat_priv,u8 type,u8 version) {struct batadv_tvlv_container *tvlv_tmp, *tvlv =NULL ;
net/batman-adv/network-coding.c +9 -9
@@ -793,10 +793,10 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv,* * Return: the nc_node if found, NULL otherwise. */ -static struct batadv_nc_node -*batadv_nc_find_nc_node (struct batadv_orig_node *orig_node, -struct batadv_orig_node *orig_neigh_node, -bool in_coding) +static struct batadv_nc_node * +batadv_nc_find_nc_node (struct batadv_orig_node *orig_node, +struct batadv_orig_node *orig_neigh_node, +bool in_coding) {struct batadv_nc_node *nc_node, *nc_node_out =NULL ;struct list_head *list;
@@ -835,11 +835,11 @@ static struct batadv_nc_node* * Return: the nc_node if found or created, NULL in case of an error. */ -static struct batadv_nc_node -*batadv_nc_get_nc_node (struct batadv_priv *bat_priv, -struct batadv_orig_node *orig_node, -struct batadv_orig_node *orig_neigh_node, -bool in_coding) +static struct batadv_nc_node * +batadv_nc_get_nc_node (struct batadv_priv *bat_priv, +struct batadv_orig_node *orig_node, +struct batadv_orig_node *orig_neigh_node, +bool in_coding) {struct batadv_nc_node *nc_node;spinlock_t *lock;/* Used to lock list selected by "int in_coding" */
Signature · 1 line
2.8.2
PATCH 12/15 batman-adv: fix debuginfo macro style issue
In reply to Antonio QuartulliFrom: Simon Wunderlich <[email protected]>
Structure initialization within the macros should follow the general coding style used in the kernel: put the initialization of the first variable and the closing brace on a separate line.
--- net/batman-adv/debugfs.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
net/batman-adv/debugfs.c +11 -8
@@ -365,14 +365,17 @@ static int batadv_nc_nodes_open(struct inode *inode, struct file *file)#define BATADV_DEBUGINFO (_name, _mode, _open) \ struct batadv_debuginfo batadv_debuginfo_##_name = { \ - .attr = { .name = __stringify(_name), \ - .mode = _mode, }, \ - .fops = { .owner = THIS_MODULE, \ - .open = _open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ - } \ + .attr = { \ + .name = __stringify(_name), \ + .mode = _mode, \ + }, \ + .fops = { \ + .owner = THIS_MODULE, \ + .open = _open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ + }, \ }/* the following attributes are general and therefore they will be directly
Signature · 1 line
2.8.2
PATCH 12/15 batman-adv: fix debuginfo macro style issue
In reply to Antonio QuartulliFrom: Simon Wunderlich <[email protected]>
Structure initialization within the macros should follow the general coding style used in the kernel: put the initialization of the first variable and the closing brace on a separate line.
--- net/batman-adv/debugfs.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
net/batman-adv/debugfs.c +11 -8
@@ -365,14 +365,17 @@ static int batadv_nc_nodes_open(struct inode *inode, struct file *file)#define BATADV_DEBUGINFO (_name, _mode, _open) \ struct batadv_debuginfo batadv_debuginfo_##_name = { \ - .attr = { .name = __stringify(_name), \ - .mode = _mode, }, \ - .fops = { .owner = THIS_MODULE, \ - .open = _open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ - } \ + .attr = { \ + .name = __stringify(_name), \ + .mode = _mode, \ + }, \ + .fops = { \ + .owner = THIS_MODULE, \ + .open = _open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ + }, \ }/* the following attributes are general and therefore they will be directly
Signature · 1 line
2.8.2
PATCH 13/15 batman-adv: move and restructure batadv_v_ogm_forward
In reply to Antonio QuartulliFrom: Simon Wunderlich <[email protected]>
To match our code better to the protocol description of B.A.T.M.A.N. V, move batadv_v_ogm_forward() out into batadv_v_ogm_process_per_outif() and move all checks directly deciding whether the OGM should be forwarded into batadv_v_ogm_forward().
--- net/batman-adv/bat_v_ogm.c | 110 ++++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 47 deletions(-)
net/batman-adv/bat_v_ogm.c +63 -47
@@ -347,10 +347,12 @@ static u32 batadv_v_forward_penalty(struct batadv_priv *bat_priv, }/** -* batadv_v_ogm_forward - forward an OGM to the given outgoing interface +* batadv_v_ogm_forward - check conditions and forward an OGM to the given +* outgoing interface * @bat_priv: the bat priv with all the soft interface information * @ogm_received: previously received OGM to be forwarded -* @throughput: throughput to announce, may vary per outgoing interface +* @orig_node: the originator which has been updated +* @neigh_node: the neigh_node through with the OGM has been received * @if_incoming: the interface on which this OGM was received on * @if_outgoing: the interface to which the OGM has to be forwarded to *
@@ -359,28 +361,57 @@ static u32 batadv_v_forward_penalty(struct batadv_priv *bat_priv,*/ static void batadv_v_ogm_forward (struct batadv_priv *bat_priv,const struct batadv_ogm2_packet *ogm_received, -u32 throughput, +struct batadv_orig_node *orig_node, +struct batadv_neigh_node *neigh_node,struct batadv_hard_iface *if_incoming,struct batadv_hard_iface *if_outgoing) { +struct batadv_neigh_ifinfo *neigh_ifinfo =NULL ; +struct batadv_orig_ifinfo *orig_ifinfo =NULL ; +struct batadv_neigh_node *router =NULL ;struct batadv_ogm2_packet *ogm_forward;unsigned char *skb_buff;struct sk_buff *skb;size_t packet_len;u16 tvlv_len; +/* only forward for specific interfaces, not for the default one. */ +if (if_outgoing ==BATADV_IF_DEFAULT ) + goto out; + + orig_ifinfo =batadv_orig_ifinfo_new (orig_node, if_outgoing); +if (!orig_ifinfo) + goto out; + +/* acquire possibly updated router */ + router =batadv_orig_router_get (orig_node, if_outgoing); + +/* strict rule: forward packets coming from the best next hop only */ +if (neigh_node != router) + goto out; + +/* don't forward the same seqno twice on one interface */ +if (orig_ifinfo->last_seqno_forwarded ==ntohl (ogm_received->seqno)) + goto out; + + orig_ifinfo->last_seqno_forwarded =ntohl (ogm_received->seqno); +if (ogm_received->ttl <=1 ) {batadv_dbg (BATADV_DBG_BATMAN , bat_priv,"ttl exceeded\n" ); -return ; + goto out; } + neigh_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); +if (!neigh_ifinfo) + goto out; + tvlv_len =ntohs (ogm_received->tvlv_len); packet_len =BATADV_OGM2_HLEN + tvlv_len; skb =netdev_alloc_skb_ip_align (if_outgoing->net_dev,ETH_HLEN + packet_len);if (!skb) -return ; + goto out;skb_reserve (skb,ETH_HLEN ); skb_buff =skb_put (skb, packet_len);
@@ -388,15 +419,23 @@ static void batadv_v_ogm_forward(struct batadv_priv *bat_priv,/* apply forward penalty */ ogm_forward = (struct batadv_ogm2_packet *)skb_buff; - ogm_forward->throughput =htonl (throughput); + ogm_forward->throughput =htonl (neigh_ifinfo->bat_v.throughput); ogm_forward->ttl--;batadv_dbg (BATADV_DBG_BATMAN , bat_priv,"Forwarding OGM2 packet on %s: throughput %u, ttl %u, received via %s\n" , - if_outgoing->net_dev->name, throughput, ogm_forward->ttl, - if_incoming->net_dev->name); + if_outgoing->net_dev->name,ntohl (ogm_forward->throughput), + ogm_forward->ttl, if_incoming->net_dev->name);batadv_v_ogm_send_to_if (skb, if_outgoing); + +out: +if (orig_ifinfo) +batadv_orig_ifinfo_put (orig_ifinfo); +if (router) +batadv_neigh_node_put (router); +if (neigh_ifinfo) +batadv_neigh_ifinfo_put (neigh_ifinfo); }/**
@@ -493,8 +532,10 @@ out:* @neigh_node: the neigh_node through with the OGM has been received * @if_incoming: the interface where this packet was received * @if_outgoing: the interface for which the packet should be considered +* +* Return: true if the packet should be forwarded, false otherwise */ -static void batadv_v_ogm_route_update(struct batadv_priv *bat_priv, +static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv, const struct ethhdr *ethhdr, const struct batadv_ogm2_packet *ogm2, struct batadv_orig_node *orig_node,
@@ -503,14 +544,9 @@ static void batadv_v_ogm_route_update(struct batadv_priv *bat_priv, struct batadv_hard_iface *if_outgoing) {struct batadv_neigh_node *router =NULL ; -struct batadv_neigh_ifinfo *neigh_ifinfo =NULL ;struct batadv_orig_node *orig_neigh_node =NULL ; -struct batadv_orig_ifinfo *orig_ifinfo =NULL ;struct batadv_neigh_node *orig_neigh_router =NULL ; - - neigh_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); -if (!neigh_ifinfo) - goto out; +bool forward = false; orig_neigh_node =batadv_v_ogm_orig_get (bat_priv, ethhdr->h_source);if (!orig_neigh_node)
@@ -529,47 +565,20 @@ static void batadv_v_ogm_route_update(struct batadv_priv *bat_priv, goto out; } -if (router) -batadv_neigh_node_put (router); -/* Update routes, and check if the OGM is from the best next hop */ batadv_v_ogm_orig_update (bat_priv, orig_node, neigh_node, ogm2, if_outgoing); - orig_ifinfo =batadv_orig_ifinfo_new (orig_node, if_outgoing); -if (!orig_ifinfo) - goto out; - -/* don't forward the same seqno twice on one interface */ -if (orig_ifinfo->last_seqno_forwarded ==ntohl (ogm2->seqno)) - goto out; - -/* acquire possibly updated router */ - router =batadv_orig_router_get (orig_node, if_outgoing); - -/* strict rule: forward packets coming from the best next hop only */ -if (neigh_node != router) - goto out; - -/* only forward for specific interface, not for the default one. */ -if (if_outgoing !=BATADV_IF_DEFAULT ) { - orig_ifinfo->last_seqno_forwarded =ntohl (ogm2->seqno); -batadv_v_ogm_forward (bat_priv, ogm2, - neigh_ifinfo->bat_v.throughput, - if_incoming, if_outgoing); - } - + forward = true; out: -if (orig_ifinfo) -batadv_orig_ifinfo_put (orig_ifinfo);if (router)batadv_neigh_node_put (router);if (orig_neigh_router)batadv_neigh_node_put (orig_neigh_router);if (orig_neigh_node)batadv_orig_node_put (orig_neigh_node); -if (neigh_ifinfo) -batadv_neigh_ifinfo_put (neigh_ifinfo); + +return forward; }/**
@@ -592,6 +601,7 @@ batadv_v_ogm_process_per_outif(struct batadv_priv *bat_priv, struct batadv_hard_iface *if_outgoing) {int seqno_age; +bool forward;/* first, update the metric with according sanity checks */ seqno_age = batadv_v_ogm_metric_update(bat_priv, ogm2, orig_node,
@@ -610,8 +620,14 @@ batadv_v_ogm_process_per_outif(struct batadv_priv *bat_priv, ntohs(ogm2->tvlv_len));/* if the metric update went through, update routes if needed */ -batadv_v_ogm_route_update (bat_priv, ethhdr, ogm2, orig_node, - neigh_node, if_incoming, if_outgoing); + forward =batadv_v_ogm_route_update (bat_priv, ethhdr, ogm2, orig_node, + neigh_node, if_incoming, + if_outgoing); + +/* if the routes have been processed correctly, check and forward */ +if (forward) +batadv_v_ogm_forward (bat_priv, ogm2, orig_node, neigh_node, + if_incoming, if_outgoing); }/**
Signature · 1 line
2.8.2
PATCH 14/15 batman-adv: Merge batadv_v_ogm_orig_update into batadv_v_ogm_route_update
In reply to Antonio QuartulliFrom: Simon Wunderlich <[email protected]>
Since batadv_v_ogm_orig_update() was only called from one place and the calling function became very short, merge these two functions together.
This should also reflect the protocol description of B.A.T.M.A.N. V better.
--- net/batman-adv/bat_v_ogm.c | 117 ++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 71 deletions(-)
net/batman-adv/bat_v_ogm.c +46 -71
@@ -234,73 +234,6 @@ void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface) }/** -* batadv_v_ogm_orig_update - update the originator status based on the received -* OGM -* @bat_priv: the bat priv with all the soft interface information -* @orig_node: the originator to update -* @neigh_node: the neighbour the OGM has been received from (to update) -* @ogm2: the received OGM -* @if_outgoing: the interface where this OGM is going to be forwarded through -*/ -static void -batadv_v_ogm_orig_update (struct batadv_priv *bat_priv, -struct batadv_orig_node *orig_node, -struct batadv_neigh_node *neigh_node, -const struct batadv_ogm2_packet *ogm2, -struct batadv_hard_iface *if_outgoing) -{ -struct batadv_neigh_ifinfo *router_ifinfo =NULL , *neigh_ifinfo =NULL ; -struct batadv_neigh_node *router =NULL ; -s32 neigh_seq_diff; -u32 neigh_last_seqno; -u32 router_last_seqno; -u32 router_throughput, neigh_throughput; - -batadv_dbg (BATADV_DBG_BATMAN , bat_priv, -"Searching and updating originator entry of received packet\n" ); - -/* if this neighbor already is our next hop there is nothing -* to change -*/ - router =batadv_orig_router_get (orig_node, if_outgoing); -if (router == neigh_node) - goto out; - -/* don't consider neighbours with worse throughput. -* also switch route if this seqno is BATADV_V_MAX_ORIGDIFF newer than -* the last received seqno from our best next hop. -*/ -if (router) { - router_ifinfo =batadv_neigh_ifinfo_get (router, if_outgoing); - neigh_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); - -/* if these are not allocated, something is wrong. */ -if (!router_ifinfo || !neigh_ifinfo) - goto out; - - neigh_last_seqno = neigh_ifinfo->bat_v.last_seqno; - router_last_seqno = router_ifinfo->bat_v.last_seqno; - neigh_seq_diff = neigh_last_seqno - router_last_seqno; - router_throughput = router_ifinfo->bat_v.throughput; - neigh_throughput = neigh_ifinfo->bat_v.throughput; - -if ((neigh_seq_diff <BATADV_OGM_MAX_ORIGDIFF ) && - (router_throughput >= neigh_throughput)) - goto out; - } - -batadv_update_route (bat_priv, orig_node, if_outgoing, neigh_node); - -out: -if (router_ifinfo) -batadv_neigh_ifinfo_put (router_ifinfo); -if (neigh_ifinfo) -batadv_neigh_ifinfo_put (neigh_ifinfo); -if (router) -batadv_neigh_node_put (router); -} - -/** * batadv_v_forward_penalty - apply a penalty to the throughput metric forwarded * with B.A.T.M.A.N. V OGMs * @bat_priv: the bat priv with all the soft interface information
@@ -546,6 +479,11 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv,struct batadv_neigh_node *router =NULL ;struct batadv_orig_node *orig_neigh_node =NULL ;struct batadv_neigh_node *orig_neigh_router =NULL ; +struct batadv_neigh_ifinfo *router_ifinfo =NULL , *neigh_ifinfo =NULL ; +u32 router_throughput, neigh_throughput; +u32 router_last_seqno; +u32 neigh_last_seqno; +s32 neigh_seq_diff;bool forward = false; orig_neigh_node =batadv_v_ogm_orig_get (bat_priv, ethhdr->h_source);
@@ -565,11 +503,44 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv, goto out; } -/* Update routes, and check if the OGM is from the best next hop */ -batadv_v_ogm_orig_update (bat_priv, orig_node, neigh_node, ogm2, - if_outgoing); - +/* Mark the OGM to be considered for forwarding, and update routes +* if needed. +*/ forward = true; + +batadv_dbg (BATADV_DBG_BATMAN , bat_priv, +"Searching and updating originator entry of received packet\n" ); + +/* if this neighbor already is our next hop there is nothing +* to change +*/ +if (router == neigh_node) + goto out; + +/* don't consider neighbours with worse throughput. +* also switch route if this seqno is BATADV_V_MAX_ORIGDIFF newer than +* the last received seqno from our best next hop. +*/ +if (router) { + router_ifinfo =batadv_neigh_ifinfo_get (router, if_outgoing); + neigh_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); + +/* if these are not allocated, something is wrong. */ +if (!router_ifinfo || !neigh_ifinfo) + goto out; + + neigh_last_seqno = neigh_ifinfo->bat_v.last_seqno; + router_last_seqno = router_ifinfo->bat_v.last_seqno; + neigh_seq_diff = neigh_last_seqno - router_last_seqno; + router_throughput = router_ifinfo->bat_v.throughput; + neigh_throughput = neigh_ifinfo->bat_v.throughput; + +if ((neigh_seq_diff <BATADV_OGM_MAX_ORIGDIFF ) && + (router_throughput >= neigh_throughput)) + goto out; + } + +batadv_update_route (bat_priv, orig_node, if_outgoing, neigh_node); out:if (router)batadv_neigh_node_put (router);
@@ -577,6 +548,10 @@ out:batadv_neigh_node_put (orig_neigh_router);if (orig_neigh_node)batadv_orig_node_put (orig_neigh_node); +if (router_ifinfo) +batadv_neigh_ifinfo_put (router_ifinfo); +if (neigh_ifinfo) +batadv_neigh_ifinfo_put (neigh_ifinfo);return forward; }
Signature · 1 line
2.8.2
PATCH 14/15 batman-adv: Merge batadv_v_ogm_orig_update into batadv_v_ogm_route_update
In reply to Antonio QuartulliFrom: Simon Wunderlich <[email protected]>
Since batadv_v_ogm_orig_update() was only called from one place and the calling function became very short, merge these two functions together.
This should also reflect the protocol description of B.A.T.M.A.N. V better.
--- net/batman-adv/bat_v_ogm.c | 117 ++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 71 deletions(-)
net/batman-adv/bat_v_ogm.c +46 -71
@@ -234,73 +234,6 @@ void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface) }/** -* batadv_v_ogm_orig_update - update the originator status based on the received -* OGM -* @bat_priv: the bat priv with all the soft interface information -* @orig_node: the originator to update -* @neigh_node: the neighbour the OGM has been received from (to update) -* @ogm2: the received OGM -* @if_outgoing: the interface where this OGM is going to be forwarded through -*/ -static void -batadv_v_ogm_orig_update (struct batadv_priv *bat_priv, -struct batadv_orig_node *orig_node, -struct batadv_neigh_node *neigh_node, -const struct batadv_ogm2_packet *ogm2, -struct batadv_hard_iface *if_outgoing) -{ -struct batadv_neigh_ifinfo *router_ifinfo =NULL , *neigh_ifinfo =NULL ; -struct batadv_neigh_node *router =NULL ; -s32 neigh_seq_diff; -u32 neigh_last_seqno; -u32 router_last_seqno; -u32 router_throughput, neigh_throughput; - -batadv_dbg (BATADV_DBG_BATMAN , bat_priv, -"Searching and updating originator entry of received packet\n" ); - -/* if this neighbor already is our next hop there is nothing -* to change -*/ - router =batadv_orig_router_get (orig_node, if_outgoing); -if (router == neigh_node) - goto out; - -/* don't consider neighbours with worse throughput. -* also switch route if this seqno is BATADV_V_MAX_ORIGDIFF newer than -* the last received seqno from our best next hop. -*/ -if (router) { - router_ifinfo =batadv_neigh_ifinfo_get (router, if_outgoing); - neigh_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); - -/* if these are not allocated, something is wrong. */ -if (!router_ifinfo || !neigh_ifinfo) - goto out; - - neigh_last_seqno = neigh_ifinfo->bat_v.last_seqno; - router_last_seqno = router_ifinfo->bat_v.last_seqno; - neigh_seq_diff = neigh_last_seqno - router_last_seqno; - router_throughput = router_ifinfo->bat_v.throughput; - neigh_throughput = neigh_ifinfo->bat_v.throughput; - -if ((neigh_seq_diff <BATADV_OGM_MAX_ORIGDIFF ) && - (router_throughput >= neigh_throughput)) - goto out; - } - -batadv_update_route (bat_priv, orig_node, if_outgoing, neigh_node); - -out: -if (router_ifinfo) -batadv_neigh_ifinfo_put (router_ifinfo); -if (neigh_ifinfo) -batadv_neigh_ifinfo_put (neigh_ifinfo); -if (router) -batadv_neigh_node_put (router); -} - -/** * batadv_v_forward_penalty - apply a penalty to the throughput metric forwarded * with B.A.T.M.A.N. V OGMs * @bat_priv: the bat priv with all the soft interface information
@@ -546,6 +479,11 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv,struct batadv_neigh_node *router =NULL ;struct batadv_orig_node *orig_neigh_node =NULL ;struct batadv_neigh_node *orig_neigh_router =NULL ; +struct batadv_neigh_ifinfo *router_ifinfo =NULL , *neigh_ifinfo =NULL ; +u32 router_throughput, neigh_throughput; +u32 router_last_seqno; +u32 neigh_last_seqno; +s32 neigh_seq_diff;bool forward = false; orig_neigh_node =batadv_v_ogm_orig_get (bat_priv, ethhdr->h_source);
@@ -565,11 +503,44 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv, goto out; } -/* Update routes, and check if the OGM is from the best next hop */ -batadv_v_ogm_orig_update (bat_priv, orig_node, neigh_node, ogm2, - if_outgoing); - +/* Mark the OGM to be considered for forwarding, and update routes +* if needed. +*/ forward = true; + +batadv_dbg (BATADV_DBG_BATMAN , bat_priv, +"Searching and updating originator entry of received packet\n" ); + +/* if this neighbor already is our next hop there is nothing +* to change +*/ +if (router == neigh_node) + goto out; + +/* don't consider neighbours with worse throughput. +* also switch route if this seqno is BATADV_V_MAX_ORIGDIFF newer than +* the last received seqno from our best next hop. +*/ +if (router) { + router_ifinfo =batadv_neigh_ifinfo_get (router, if_outgoing); + neigh_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); + +/* if these are not allocated, something is wrong. */ +if (!router_ifinfo || !neigh_ifinfo) + goto out; + + neigh_last_seqno = neigh_ifinfo->bat_v.last_seqno; + router_last_seqno = router_ifinfo->bat_v.last_seqno; + neigh_seq_diff = neigh_last_seqno - router_last_seqno; + router_throughput = router_ifinfo->bat_v.throughput; + neigh_throughput = neigh_ifinfo->bat_v.throughput; + +if ((neigh_seq_diff <BATADV_OGM_MAX_ORIGDIFF ) && + (router_throughput >= neigh_throughput)) + goto out; + } + +batadv_update_route (bat_priv, orig_node, if_outgoing, neigh_node); out:if (router)batadv_neigh_node_put (router);
@@ -577,6 +548,10 @@ out:batadv_neigh_node_put (orig_neigh_router);if (orig_neigh_node)batadv_orig_node_put (orig_neigh_node); +if (router_ifinfo) +batadv_neigh_ifinfo_put (router_ifinfo); +if (neigh_ifinfo) +batadv_neigh_ifinfo_put (neigh_ifinfo);return forward; }
Signature · 1 line
2.8.2
PATCH 15/15 batman-adv: Split batadv_iv_ogm_orig_del_if function
In reply to Antonio QuartulliFrom: Sven Eckelmann <[email protected]>
batadv_iv_ogm_orig_del_if handles two different buffers bcast_own and bcast_own_sum which should be resized. The error handling two for allocating these buffers causes the complexity of this function. This can be avoided completely when the function is split into a main function handling the locking, freeing and call of the subfunctions.
The subfunction can then independently handle the resize of the buffers. This also allows to easily reuse the old buffer (which always is larger) in case a smaller buffer could not be allocated without increasing the code complexity.
--- net/batman-adv/bat_iv_ogm.c | 131 ++++++++++++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 47 deletions(-)
net/batman-adv/bat_iv_ogm.c +84 -47
@@ -32,6 +32,7 @@#include <linux/jiffies.h> #include <linux/list.h> #include <linux/kref.h> +#include <linux/lockdep.h> #include <linux/netdevice.h> #include <linux/pkt_sched.h> #include <linux/printk.h>
@@ -175,6 +176,79 @@ unlock: }/** +* batadv_iv_ogm_drop_bcast_own_entry - drop section of bcast_own +* @orig_node: the orig_node that has to be changed +* @max_if_num: the current amount of interfaces +* @del_if_num: the index of the interface being removed +*/ +static void +batadv_iv_ogm_drop_bcast_own_entry (struct batadv_orig_node *orig_node, +int max_if_num,int del_if_num) +{ +size_t chunk_size; +size_t if_offset; +void *data_ptr; + +lockdep_assert_held (&orig_node->bat_iv.ogm_cnt_lock); + + chunk_size =sizeof (unsigned long ) *BATADV_NUM_WORDS ; + data_ptr =kmalloc_array (max_if_num, chunk_size,GFP_ATOMIC ); +if (!data_ptr) +/* use old buffer when new one could not be allocated */ + data_ptr = orig_node->bat_iv.bcast_own; + +/* copy first part */ +memmove (data_ptr, orig_node->bat_iv.bcast_own, del_if_num * chunk_size); + +/* copy second part */ + if_offset = (del_if_num +1 ) * chunk_size; +memmove ((char *)data_ptr + del_if_num * chunk_size, + (uint8_t *)orig_node->bat_iv.bcast_own + if_offset, + (max_if_num - del_if_num) * chunk_size); + +/* bcast_own was shrunk down in new buffer; free old one */ +if (orig_node->bat_iv.bcast_own != data_ptr) { +kfree (orig_node->bat_iv.bcast_own); + orig_node->bat_iv.bcast_own = data_ptr; + } +} + +/** +* batadv_iv_ogm_drop_bcast_own_sum_entry - drop section of bcast_own_sum +* @orig_node: the orig_node that has to be changed +* @max_if_num: the current amount of interfaces +* @del_if_num: the index of the interface being removed +*/ +static void +batadv_iv_ogm_drop_bcast_own_sum_entry (struct batadv_orig_node *orig_node, +int max_if_num,int del_if_num) +{ +size_t if_offset; +void *data_ptr; + +lockdep_assert_held (&orig_node->bat_iv.ogm_cnt_lock); + + data_ptr =kmalloc_array (max_if_num,sizeof (u8),GFP_ATOMIC ); +if (!data_ptr) +/* use old buffer when new one could not be allocated */ + data_ptr = orig_node->bat_iv.bcast_own_sum; + +memmove (data_ptr, orig_node->bat_iv.bcast_own_sum, + del_if_num *sizeof (u8)); + + if_offset = (del_if_num +1 ) *sizeof (u8); +memmove ((char *)data_ptr + del_if_num *sizeof (u8), + orig_node->bat_iv.bcast_own_sum + if_offset, + (max_if_num - del_if_num) *sizeof (u8)); + +/* bcast_own_sum was shrunk down in new buffer; free old one */ +if (orig_node->bat_iv.bcast_own_sum != data_ptr) { +kfree (orig_node->bat_iv.bcast_own_sum); + orig_node->bat_iv.bcast_own_sum = data_ptr; + } +} + +/** * batadv_iv_ogm_orig_del_if - change the private structures of the orig_node to * exclude the removed interface * @orig_node: the orig_node that has to be changed
@@ -186,60 +260,23 @@ unlock:static int batadv_iv_ogm_orig_del_if (struct batadv_orig_node *orig_node,int max_if_num,int del_if_num) { -int ret = -ENOMEM ; -size_t chunk_size, if_offset; -void *data_ptr =NULL ; -spin_lock_bh (&orig_node->bat_iv.ogm_cnt_lock); -/* last interface was removed */ -if (max_if_num ==0 ) - goto free_bcast_own; - - chunk_size =sizeof (unsigned long ) *BATADV_NUM_WORDS ; - data_ptr =kmalloc_array (max_if_num, chunk_size,GFP_ATOMIC ); -if (!data_ptr) - goto unlock; - -/* copy first part */ -memcpy (data_ptr, orig_node->bat_iv.bcast_own, del_if_num * chunk_size); - -/* copy second part */ - if_offset = (del_if_num +1 ) * chunk_size; -memcpy ((char *)data_ptr + del_if_num * chunk_size, - (uint8_t *)orig_node->bat_iv.bcast_own + if_offset, - (max_if_num - del_if_num) * chunk_size); - -free_bcast_own: -kfree (orig_node->bat_iv.bcast_own); - orig_node->bat_iv.bcast_own = data_ptr; - -if (max_if_num ==0 ) - goto free_own_sum; - - data_ptr =kmalloc_array (max_if_num,sizeof (u8),GFP_ATOMIC ); -if (!data_ptr) { +if (max_if_num ==0 ) {kfree (orig_node->bat_iv.bcast_own); - goto unlock; +kfree (orig_node->bat_iv.bcast_own_sum); + orig_node->bat_iv.bcast_own =NULL ; + orig_node->bat_iv.bcast_own_sum =NULL ; + }else { +batadv_iv_ogm_drop_bcast_own_entry (orig_node, max_if_num, + del_if_num); +batadv_iv_ogm_drop_bcast_own_sum_entry (orig_node, max_if_num, + del_if_num); } -memcpy (data_ptr, orig_node->bat_iv.bcast_own_sum, - del_if_num *sizeof (u8)); - - if_offset = (del_if_num +1 ) *sizeof (u8); -memcpy ((char *)data_ptr + del_if_num *sizeof (u8), - orig_node->bat_iv.bcast_own_sum + if_offset, - (max_if_num - del_if_num) *sizeof (u8)); - -free_own_sum: -kfree (orig_node->bat_iv.bcast_own_sum); - orig_node->bat_iv.bcast_own_sum = data_ptr; - - ret =0 ; -unlock:spin_unlock_bh (&orig_node->bat_iv.ogm_cnt_lock); -return ret; +return 0 ; }/**
Signature · 1 line
2.8.2
A message that is not in the archive (sent off-list or not yet received): 1462314230-16257-1-git-send-email-a-2CpIooy/[email protected]
From: Antonio Quartulli <[email protected]>
Date: Wed, 4 May 2016 06:23:35 +0800
Quoted 10 lines
this is a pull request intended for net-next.
In this batch you don't have any patch that depends on our fixes, therefore you can safely merge it even if the net tree has not been merged yet.
In this patchset you basically have some cleanup work, code refactoring, style fixes and two updates for the
MAINTAINERSfile.Please pull or let me know of any problem!
Pulled, thanks Antonio.