Redundancy bonding mode patches, v1
Hi everyone,
The following patches add a redundancy bonding mode to batman-adv: In case of multiple interfaces available towards a next hop node, instead of sending packets in interface alternating or round robin bonding fashion, packets get send redundantly on all available interfaces available for bonding.
This mode increases the packet delivery ratio of unicast data transfers for the cost of throughput in multi interface mesh networks and is therefore aimed at high reliability mesh networks.
It is especially useful if the main source of packet loss is not always reliably detectable by batman-adv's broadcast PDR measurements (i.e. bursty periods of interference on a single channel, which gets averaged out due to the windowing; different unicast bitrate; ...). Or if a fault tolerant packet forwarding scheme which is able to tolerate a sudden link failure with no impact on the user experience is required.
The first eight patches are mainly some restructuring of the unicast sending code paths. Patches nine to 13 add the actual redandancy bonding mode.
Please note, that this redundancy bonding mode is not yet compatible with batman-adv's link layer fragmentation feature.
Cheers, Linus
PATCH 1/13 batman-adv: Remove unused hdr_size variable in route_unicast_packet()
--- routing.c | 7 +++---- routing.h | 3 +-- soft-interface.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-)
batman-adv/routing.c +3 -4
@@ -1280,8 +1280,7 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)return 0 ; } -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, -int hdr_size) +int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if) {struct bat_priv *bat_priv =netdev_priv (recv_if->soft_iface);struct orig_node *orig_node =NULL ;
@@ -1385,7 +1384,7 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (skb, recv_if, hdr_size); +return route_unicast_packet (skb, recv_if); }int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if)
@@ -1418,7 +1417,7 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (skb, recv_if, hdr_size); +return route_unicast_packet (skb, recv_if); }
batman-adv/routing.h +1 -2
@@ -30,8 +30,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,void update_routes (struct bat_priv *bat_priv,struct orig_node *orig_node,struct neigh_node *neigh_node,unsigned char *hna_buff,int hna_buff_len); -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, -int hdr_size); +int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if);
batman-adv/soft-interface.c +1 -1
@@ -482,7 +482,7 @@ void interface_rx(struct net_device *soft_iface,memcpy (unicast_packet->dest, bat_priv->softif_neigh->addr,ETH_ALEN ); - ret =route_unicast_packet (skb, recv_if, hdr_size); + ret =route_unicast_packet (skb, recv_if);if (ret ==NET_RX_DROP ) goto dropped;
Signature · 1 line
1.7.2.3
PATCH 2/13 batman-adv: Add explicit batman header structure
In reply to Linus LüssingJust a minor style adjustment, to give people a hint which fields should not be reordered and need to be at the beginning of each packet with batman-adv's frame type.
--- aggregation.c | 4 ++-- hard-interface.c | 18 +++++++++--------- icmp_socket.c | 6 +++--- packet.h | 52 ++++++++++++++++++++++------------------------------ routing.c | 34 +++++++++++++++++----------------- send.c | 20 ++++++++++---------- soft-interface.c | 14 +++++++------- unicast.c | 16 ++++++++-------- vis.c | 14 +++++++------- 9 files changed, 85 insertions(+), 93 deletions(-)
batman-adv/aggregation.c +2 -2
@@ -69,7 +69,7 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,* are flooded through the net */ if ((!directlink) && (!(batman_packet->flags & DIRECTLINK)) && - (batman_packet->ttl != 1) && + (batman_packet->header.ttl != 1) &&/* own packets originating non-primary * interfaces leave only that interface */
@@ -80,7 +80,7 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,/* if the incoming packet is sent via this one * interface only - we still can aggregate */ if ((directlink) && - (new_batman_packet->ttl == 1) && + (new_batman_packet->header.ttl == 1) && (forw_packet->if_incoming == if_incoming) &&/* packets from direct neighbors or
batman-adv/hard-interface.c +9 -9
@@ -146,8 +146,8 @@ static void set_primary_if(struct bat_priv *bat_priv,return ; batman_packet = (struct batman_packet *)(batman_if->packet_buff); + batman_packet->header.ttl =TTL ; batman_packet->flags =PRIMARIES_FIRST_HOP ; - batman_packet->ttl =TTL ;update_primary_addr (bat_priv);
@@ -312,10 +312,10 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name) } batman_packet = (struct batman_packet *)(batman_if->packet_buff); - batman_packet->packet_type =BAT_PACKET ; - batman_packet->version =COMPAT_VERSION ; + batman_packet->header.packet_type =BAT_PACKET ; + batman_packet->header.version =COMPAT_VERSION ; + batman_packet->header.ttl =2 ; batman_packet->flags =0 ; - batman_packet->ttl =2 ; batman_packet->tq =TQ_MAX_VALUE ; batman_packet->num_hna =0 ;
@@ -558,7 +558,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, struct net_device *orig_dev) {struct bat_priv *bat_priv; -struct batman_packet *batman_packet; +struct batman_header *batman_header;struct batman_if *batman_if;int ret;
@@ -590,19 +590,19 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,if (batman_if->if_status !=IF_ACTIVE ) goto err_free; - batman_packet = (struct batman_packet *)skb->data; + batman_header = (struct batman_header *)skb->data; -if (batman_packet->version !=COMPAT_VERSION ) { +if (batman_header->version !=COMPAT_VERSION ) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: incompatible batman version (%i)\n" , - batman_packet->version); + batman_header->version); goto err_free; }/* all receive handlers return whether they received or reused * the supplied skb. if not, we have to free the skb. */ -switch (batman_packet->packet_type) { +switch (batman_header->packet_type) {/* batman originator packet */ case BAT_PACKET : ret =recv_bat_packet (skb, batman_if);
batman-adv/icmp_socket.c +3 -3
@@ -190,7 +190,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, goto free_skb; } -if (icmp_packet->packet_type !=BAT_ICMP ) { +if (icmp_packet->header.packet_type !=BAT_ICMP ) {bat_dbg (DBG_BATMAN , bat_priv,"Error - can't send packet from char device: " "got bogus packet type (expected: BAT_ICMP)\n" );
@@ -208,9 +208,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, icmp_packet->uid = socket_client->index; -if (icmp_packet->version !=COMPAT_VERSION ) { +if (icmp_packet->header.version !=COMPAT_VERSION ) { + icmp_packet->header.ttl =COMPAT_VERSION ; icmp_packet->msg_type =PARAMETER_PROBLEM ; - icmp_packet->ttl =COMPAT_VERSION ;bat_socket_add_packet (socket_client, icmp_packet, packet_len); goto free_skb; }
batman-adv/packet.h +22 -30
103 lines not on this page · raw message
batman-adv/routing.c +17 -17
@@ -441,8 +441,8 @@ static void update_orig(struct bat_priv *bat_priv, neigh_node->tq_avg =ring_buffer_avg (neigh_node->tq_recv);if (!is_duplicate) { - orig_node->last_ttl = batman_packet->ttl; - neigh_node->last_ttl = batman_packet->ttl; + orig_node->last_ttl = batman_packet->header.ttl; + neigh_node->last_ttl = batman_packet->header.ttl; }bonding_candidate_add (orig_node, neigh_node);
@@ -632,7 +632,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,* packet in an aggregation. Here we expect that the padding * is always zero (or not 0x01) */ -if (batman_packet->packet_type !=BAT_PACKET ) +if (batman_packet->header.packet_type !=BAT_PACKET )return ;/* could be changed by schedule_own_packet() */
@@ -650,8 +650,8 @@ void receive_bat_packet(struct ethhdr *ethhdr, ethhdr->h_source, if_incoming->net_dev->name, if_incoming->net_dev->dev_addr, batman_packet->orig, batman_packet->prev_sender, batman_packet->seqno, - batman_packet->tq, batman_packet->ttl, batman_packet->version, - has_directlink_flag); + batman_packet->tq, batman_packet->header.ttl, + batman_packet->header.version, has_directlink_flag);rcu_read_lock ();list_for_each_entry_rcu (batman_if, &if_list, list) {
@@ -678,10 +678,10 @@ void receive_bat_packet(struct ethhdr *ethhdr, }rcu_read_unlock (); -if (batman_packet->version !=COMPAT_VERSION ) { +if (batman_packet->header.version !=COMPAT_VERSION ) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: incompatible batman version (%i)\n" , - batman_packet->version); + batman_packet->header.version);return ; }
@@ -798,7 +798,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,if (is_bidirectional && (!is_duplicate || ((orig_node->last_real_seqno == batman_packet->seqno) && - (orig_node->last_ttl -3 <= batman_packet->ttl)))) + (orig_node->last_ttl -3 <= batman_packet->header.ttl))))update_orig (bat_priv, orig_node, ethhdr, batman_packet, if_incoming, hna_buff, hna_buff_len, is_duplicate);
@@ -927,7 +927,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,memcpy (icmp_packet->orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN ); icmp_packet->msg_type =ECHO_REPLY ; - icmp_packet->ttl =TTL ; + icmp_packet->header.ttl =TTL ;send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); ret =NET_RX_SUCCESS ;
@@ -995,7 +995,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,memcpy (icmp_packet->orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN ); icmp_packet->msg_type =TTL_EXCEEDED ; - icmp_packet->ttl =TTL ; + icmp_packet->header.ttl =TTL ;send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); ret =NET_RX_SUCCESS ;
@@ -1061,7 +1061,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if)return recv_my_icmp_packet (bat_priv, skb, hdr_size);/* TTL exceeded */ -if (icmp_packet->ttl <2 ) +if (icmp_packet->header.ttl <2 )return recv_icmp_ttl_exceeded (bat_priv, skb);/* get routing information */
@@ -1092,7 +1092,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if) icmp_packet = (struct icmp_packet_rr *)skb->data;/* decrement ttl */ - icmp_packet->ttl--; + icmp_packet->header.ttl--;/* route it */ send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr);
@@ -1293,7 +1293,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) unicast_packet = (struct unicast_packet *)skb->data;/* TTL exceeded */ -if (unicast_packet->ttl <2 ) { +if (unicast_packet->header.ttl <2 ) {pr_debug ("Warning - can't forward unicast packet from %pM to " "%pM: ttl exceeded\n" , ethhdr->h_source, unicast_packet->dest);
@@ -1324,7 +1324,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) unicast_packet = (struct unicast_packet *)skb->data; -if (unicast_packet->packet_type ==BAT_UNICAST && +if (unicast_packet->header.packet_type ==BAT_UNICAST &&atomic_read (&bat_priv->fragmentation) && skb->len > neigh_node->if_incoming->net_dev->mtu) { ret = frag_send_skb(skb, bat_priv,
@@ -1332,7 +1332,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) goto out; } -if (unicast_packet->packet_type ==BAT_UNICAST_FRAG && +if (unicast_packet->header.packet_type ==BAT_UNICAST_FRAG &&frag_can_reassemble (skb, neigh_node->if_incoming->net_dev->mtu)) { ret =frag_reassemble_skb (skb, bat_priv, &new_skb);
@@ -1351,7 +1351,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) }/* decrement ttl */ - unicast_packet->ttl--; + unicast_packet->header.ttl--;/* route it */ send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr);
@@ -1455,7 +1455,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if)if (is_my_mac (bcast_packet->orig)) goto out; -if (bcast_packet->ttl <2 ) +if (bcast_packet->header.ttl <2 ) goto out;rcu_read_lock ();
batman-adv/send.c +10 -10
@@ -139,7 +139,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet," IDF %s) on interface %s [%pM]\n" , fwd_str, (packet_num >0 ?"aggregated " :"" ), batman_packet->orig,ntohl (batman_packet->seqno), - batman_packet->tq, batman_packet->ttl, + batman_packet->tq, batman_packet->header.ttl, (batman_packet->flags &DIRECTLINK ?"on" :"off" ), batman_if->net_dev->name, batman_if->net_dev->dev_addr);
@@ -181,7 +181,7 @@ static void send_packet(struct forw_packet *forw_packet)/* multihomed peer assumed */ /* non-primary OGMs are only broadcasted on their interface */ -if ((directlink && (batman_packet->ttl ==1 )) || +if ((directlink && (batman_packet->header.ttl ==1 )) || (forw_packet->own && (forw_packet->if_incoming->if_num >0 ))) {/* FIXME: what about aggregated packets ? */
@@ -190,7 +190,7 @@ static void send_packet(struct forw_packet *forw_packet)"on interface %s [%pM]\n" , (forw_packet->own ?"Sending own" :"Forwarding" ), batman_packet->orig,ntohl (batman_packet->seqno), - batman_packet->ttl, + batman_packet->header.ttl, forw_packet->if_incoming->net_dev->name, forw_packet->if_incoming->net_dev->dev_addr);
@@ -310,15 +310,15 @@ void schedule_forward_packet(struct orig_node *orig_node,unsigned char in_tq, in_ttl, tq_avg =0 ;unsigned long send_time; -if (batman_packet->ttl <=1 ) { +if (batman_packet->header.ttl <=1 ) {bat_dbg (DBG_BATMAN , bat_priv,"ttl exceeded\n" );return ; } in_tq = batman_packet->tq; - in_ttl = batman_packet->ttl; + in_ttl = batman_packet->header.ttl; - batman_packet->ttl--; + batman_packet->header.ttl--;memcpy (batman_packet->prev_sender, ethhdr->h_source,ETH_ALEN );/* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
@@ -330,8 +330,8 @@ void schedule_forward_packet(struct orig_node *orig_node, batman_packet->tq = orig_node->router->tq_avg;if (orig_node->router->last_ttl) - batman_packet->ttl = orig_node->router->last_ttl - -1 ; + batman_packet->header.ttl = + orig_node->router->last_ttl -1 ; } tq_avg = orig_node->router->tq_avg;
@@ -344,7 +344,7 @@ void schedule_forward_packet(struct orig_node *orig_node,"Forwarding packet: tq_orig: %i, tq_avg: %i, " "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n" , in_tq, tq_avg, batman_packet->tq, in_ttl -1 , - batman_packet->ttl); + batman_packet->header.ttl); batman_packet->seqno =htonl (batman_packet->seqno);
@@ -420,7 +420,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *skb)/* as we have a copy now, it is safe to decrease the TTL */ bcast_packet = (struct bcast_packet *)skb->data; - bcast_packet->ttl--; + bcast_packet->header.ttl--;skb_reset_mac_header (skb);
batman-adv/soft-interface.c +7 -7
@@ -226,10 +226,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,else batman_packet = (struct batman_packet *)(skb->data +ETH_HLEN ); -if (batman_packet->version !=COMPAT_VERSION ) +if (batman_packet->header.version !=COMPAT_VERSION ) goto err; -if (batman_packet->packet_type !=BAT_PACKET ) +if (batman_packet->header.packet_type !=BAT_PACKET ) goto err;if (!(batman_packet->flags &PRIMARIES_FIRST_HOP ))
@@ -393,11 +393,11 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) goto dropped; bcast_packet = (struct bcast_packet *)skb->data; - bcast_packet->version =COMPAT_VERSION ; - bcast_packet->ttl =TTL ; + bcast_packet->header.version =COMPAT_VERSION ; + bcast_packet->header.ttl =TTL ;/* batman packet type: broadcast */ - bcast_packet->packet_type =BAT_BCAST ; + bcast_packet->header.packet_type =BAT_BCAST ;/* hw address of first interface is the orig mac because only * this mac is known throughout the mesh */
@@ -474,8 +474,8 @@ void interface_rx(struct net_device *soft_iface,skb_push (skb, hdr_size); unicast_packet = (struct unicast_packet *)skb->data; -if ((unicast_packet->packet_type !=BAT_UNICAST ) && - (unicast_packet->packet_type !=BAT_UNICAST_FRAG )) +if ((unicast_packet->header.packet_type !=BAT_UNICAST ) && + (unicast_packet->header.packet_type !=BAT_UNICAST_FRAG )) goto dropped;skb_reset_mac_header (skb);
batman-adv/unicast.c +8 -8
@@ -67,7 +67,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,memmove (skb->data + uni_diff, skb->data, hdr_len); unicast_packet = (struct unicast_packet *)skb_pull (skb, uni_diff); - unicast_packet->packet_type =BAT_UNICAST ; + unicast_packet->header.packet_type =BAT_UNICAST ;return skb;
@@ -260,9 +260,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,memcpy (frag1, &tmp_uc,sizeof (struct unicast_packet )); - frag1->ttl--; - frag1->version =COMPAT_VERSION ; - frag1->packet_type =BAT_UNICAST_FRAG ; + frag1->header.ttl--; + frag1->header.version =COMPAT_VERSION ; + frag1->header.packet_type =BAT_UNICAST_FRAG ;memcpy (frag1->orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN );memcpy (frag2, frag1,sizeof (struct unicast_frag_packet ));
@@ -326,11 +326,11 @@ find_router: unicast_packet = (struct unicast_packet *)skb->data; - unicast_packet->version =COMPAT_VERSION ; + unicast_packet->header.version =COMPAT_VERSION ;/* batman packet type: unicast */ - unicast_packet->packet_type =BAT_UNICAST ; + unicast_packet->header.packet_type =BAT_UNICAST ;/* set unicast ttl */ - unicast_packet->ttl =TTL ; + unicast_packet->header.ttl =TTL ;/* copy the destination for faster routing */ memcpy (unicast_packet->dest, orig_node->orig,ETH_ALEN );
@@ -338,7 +338,7 @@ find_router: data_len + sizeof(struct unicast_packet) > neigh_node->if_incoming->net_dev->mtu) {/* send frag skb decreases ttl */ - unicast_packet->ttl++; + unicast_packet->header.ttl++; ret =frag_send_skb (skb, bat_priv, neigh_node->if_incoming, neigh_node->addr); goto out;
batman-adv/vis.c +7 -7
@@ -592,7 +592,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) packet->vis_type =atomic_read (&bat_priv->vis_mode);memcpy (packet->target_orig, broadcast_addr,ETH_ALEN ); - packet->ttl =TTL ; + packet->header.ttl =TTL ; packet->seqno =htonl (ntohl (packet->seqno) +1 ); packet->entries =0 ;skb_trim (info->skb_packet,sizeof (struct vis_packet ));
@@ -806,20 +806,20 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)struct vis_packet *packet; packet = (struct vis_packet *)info->skb_packet->data; -if (packet->ttl <2 ) { +if (packet->header.ttl <2 ) {pr_debug ("Error - can't send vis packet: ttl exceeded\n" );return ; }memcpy (packet->sender_orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN ); - packet->ttl--; + packet->header.ttl--;if (is_broadcast_ether_addr (packet->target_orig))broadcast_vis_packet (bat_priv, info);else unicast_vis_packet (bat_priv, info); - packet->ttl++;/* restore TTL */ + packet->header.ttl++;/* restore TTL */ }/* called from timer; send (and maybe generate) vis packet. */
@@ -900,9 +900,9 @@ int vis_init(struct bat_priv *bat_priv)INIT_LIST_HEAD (&bat_priv->my_vis_info->send_list);kref_init (&bat_priv->my_vis_info->refcount); bat_priv->my_vis_info->bat_priv = bat_priv; - packet->version =COMPAT_VERSION ; - packet->packet_type =BAT_VIS ; - packet->ttl =TTL ; + packet->header.version =COMPAT_VERSION ; + packet->header.packet_type =BAT_VIS ; + packet->header.ttl =TTL ; packet->seqno =0 ; packet->entries =0 ;
Signature · 1 line
1.7.2.3
PATCH 3/13 batman-adv: Unify TTL handling
In reply to Linus LüssingAll our packets have a TTL and with the last batman header patch also at the same place in a batman encapsulated packet. We can therefore savely do one single TTL check before sending any batman packet type.
This commit also modifies the TTL handling to be more consistent with how it is done in other network protocols (like IPv6): The TTL is always decreased before transmitting a packet and not on receiption for one thing. And packets with a TTL of zero will never be be sent out on a network interface for another.
Compare with: RFC1812; RFC2460,4.4; RFC3443,2.3
--- aggregation.c | 2 +- hard-interface.c | 2 +- routing.c | 92 --------------------------------------- send.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++------- unicast.c | 3 - vis.c | 6 --- 6 files changed, 111 insertions(+), 119 deletions(-)
batman-adv/aggregation.c +1 -1
@@ -69,7 +69,7 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,* are flooded through the net */ if ((!directlink) && (!(batman_packet->flags & DIRECTLINK)) && - (batman_packet->header.ttl != 1) && + (batman_packet->header.ttl != 2) &&/* own packets originating non-primary * interfaces leave only that interface */
batman-adv/hard-interface.c +1 -1
@@ -314,7 +314,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name) batman_packet = (struct batman_packet *)(batman_if->packet_buff); batman_packet->header.packet_type =BAT_PACKET ; batman_packet->header.version =COMPAT_VERSION ; - batman_packet->header.ttl =2 ; + batman_packet->header.ttl =3 ; batman_packet->flags =0 ; batman_packet->tq =TQ_MAX_VALUE ; batman_packet->num_hna =0 ;
batman-adv/routing.c +0 -92
135 lines not on this page · raw message
batman-adv/send.c +109 -16
188 lines not on this page · raw message
batman-adv/unicast.c +0 -3
@@ -260,7 +260,6 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,memcpy (frag1, &tmp_uc,sizeof (struct unicast_packet )); - frag1->header.ttl--; frag1->header.version =COMPAT_VERSION ; frag1->header.packet_type =BAT_UNICAST_FRAG ;
@@ -337,8 +336,6 @@ find_router:if (atomic_read (&bat_priv->fragmentation) && data_len +sizeof (struct unicast_packet ) > neigh_node->if_incoming->net_dev->mtu) { -/* send frag skb decreases ttl */ - unicast_packet->header.ttl++; ret =frag_send_skb (skb, bat_priv, neigh_node->if_incoming, neigh_node->addr); goto out;
batman-adv/vis.c +0 -6
@@ -806,20 +806,14 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)struct vis_packet *packet; packet = (struct vis_packet *)info->skb_packet->data; -if (packet->header.ttl <2 ) { -pr_debug ("Error - can't send vis packet: ttl exceeded\n" ); -return ; - }memcpy (packet->sender_orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN ); - packet->header.ttl--;if (is_broadcast_ether_addr (packet->target_orig))broadcast_vis_packet (bat_priv, info);else unicast_vis_packet (bat_priv, info); - packet->header.ttl++;/* restore TTL */ }/* called from timer; send (and maybe generate) vis packet. */
Signature · 1 line
1.7.2.3
PATCH 4/13 batman-adv: Make route_unicast_packet() packet_type independent
In reply to Linus Lüssing--- routing.c | 20 +++++++++----------- routing.h | 3 ++- soft-interface.c | 3 ++- 3 files changed, 13 insertions(+), 13 deletions(-)
batman-adv/routing.c +9 -11
@@ -1204,22 +1204,20 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)return 0 ; } -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if) +int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, +uint8_t *dest,uint8_t packet_type) {struct bat_priv *bat_priv =netdev_priv (recv_if->soft_iface);struct orig_node *orig_node =NULL ;struct neigh_node *neigh_node =NULL ; -struct unicast_packet *unicast_packet;int ret =NET_RX_DROP ;struct sk_buff *new_skb; - unicast_packet = (struct unicast_packet *)skb->data; -/* get routing information */ rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, - unicast_packet->dest)); + dest));if (!orig_node) goto unlock;
@@ -1237,9 +1235,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)if (skb_cow (skb,sizeof (struct ethhdr )) <0 ) goto out; - unicast_packet = (struct unicast_packet *)skb->data; - -if (unicast_packet->header.packet_type ==BAT_UNICAST && +if (packet_type ==BAT_UNICAST &&atomic_read (&bat_priv->fragmentation) && skb->len > neigh_node->if_incoming->net_dev->mtu) { ret = frag_send_skb(skb, bat_priv,
@@ -1247,7 +1243,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) goto out; } -if (unicast_packet->header.packet_type ==BAT_UNICAST_FRAG && +if (packet_type ==BAT_UNICAST_FRAG &&frag_can_reassemble (skb, neigh_node->if_incoming->net_dev->mtu)) { ret =frag_reassemble_skb (skb, bat_priv, &new_skb);
@@ -1295,7 +1291,8 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (skb, recv_if); +return route_unicast_packet (skb, recv_if, unicast_packet->dest, + unicast_packet->header.packet_type); }int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if)
@@ -1328,7 +1325,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (skb, recv_if); +return route_unicast_packet (skb, recv_if, unicast_packet->dest, + unicast_packet->header.packet_type); }
batman-adv/routing.h +2 -1
@@ -30,7 +30,8 @@ void receive_bat_packet(struct ethhdr *ethhdr,void update_routes (struct bat_priv *bat_priv,struct orig_node *orig_node,struct neigh_node *neigh_node,unsigned char *hna_buff,int hna_buff_len); -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if); +int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, +uint8_t *dest,uint8_t packet_type);int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if);
batman-adv/soft-interface.c +2 -1
@@ -482,7 +482,8 @@ void interface_rx(struct net_device *soft_iface,memcpy (unicast_packet->dest, bat_priv->softif_neigh->addr,ETH_ALEN ); - ret =route_unicast_packet (skb, recv_if); + ret =route_unicast_packet (skb, recv_if, unicast_packet->dest, + unicast_packet->header.packet_type);if (ret ==NET_RX_DROP ) goto dropped;
Signature · 1 line
1.7.2.3
PATCH 5/13 batman-adv: Add rcu-refcount wrapper for orig_node hash_find()
In reply to Linus LüssingThis structure is being used in several places - removing some redundancy.
--- hash.h | 18 +++++++++++++++ icmp_socket.c | 21 +++++------------ originator.c | 11 +------- routing.c | 67 +++++++++++++------------------------------------------- send.c | 20 +++++------------ unicast.c | 14 +---------- 6 files changed, 50 insertions(+), 101 deletions(-)
batman-adv/hash.h +18 -0
@@ -23,6 +23,7 @@#define _NET_BATMAN_ADV_HASH_H_#include <linux/list.h> +#include "originator.h" /* callback to a compare function. should * compare 2 element datas for their keys,
@@ -193,4 +194,21 @@ static inline void *hash_find(struct hashtable_t *hash, return bucket_data; } +/* increases the orig_node's refcount, if found */ +static inline struct orig_node *hash_find_orig (struct bat_priv *bat_priv, +uint8_t *dest) +{ +struct hashtable_t *hash = bat_priv->orig_hash; +struct orig_node *orig_node; + +rcu_read_lock (); + + orig_node =hash_find (hash, compare_orig, choose_orig, dest); +if (orig_node) +kref_get (&orig_node->refcount); + +rcu_read_unlock (); +return orig_node; +} +#endif /* _NET_BATMAN_ADV_HASH_H_ */
batman-adv/icmp_socket.c +6 -15
@@ -218,23 +218,16 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,if (atomic_read (&bat_priv->mesh_state) !=MESH_ACTIVE ) goto dst_unreach; -rcu_read_lock (); - orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, - compare_orig, choose_orig, - icmp_packet->dst)); - + orig_node =hash_find_orig (bat_priv, icmp_packet->dst);if (!orig_node) - goto unlock; + goto dst_unreach; -kref_get (&orig_node->refcount); +rcu_read_lock (); neigh_node = orig_node->router; - -if (!neigh_node) - goto unlock; - -if (!atomic_inc_not_zero (&neigh_node->refcount)) { +if (!neigh_node || !atomic_inc_not_zero (&neigh_node->refcount)) { neigh_node =NULL ; - goto unlock; +rcu_read_unlock (); + goto dst_unreach; }rcu_read_unlock ();
@@ -255,8 +248,6 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); goto out; -unlock: -rcu_read_unlock (); dst_unreach: icmp_packet->msg_type =DESTINATION_UNREACHABLE ;bat_socket_add_packet (socket_client, icmp_packet, packet_len);
batman-adv/originator.c +2 -9
@@ -189,16 +189,9 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)int size;int hash_added; -rcu_read_lock (); - orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, - compare_orig, choose_orig, - addr)); -rcu_read_unlock (); - -if (orig_node) { -kref_get (&orig_node->refcount); + orig_node =hash_find_orig (bat_priv, addr); +if (orig_node)return orig_node; - }bat_dbg (DBG_BATMAN , bat_priv,"Creating new originator: %pM\n" , addr);
batman-adv/routing.c +16 -51
125 lines not on this page · raw message
batman-adv/send.c +6 -14
@@ -76,22 +76,16 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, goto out;/* get routing information */ -rcu_read_lock (); - orig_node = ((struct orig_node *) -hash_find (bat_priv->orig_hash, compare_orig, choose_orig, - icmp_packet->orig)); + orig_node =hash_find_orig (bat_priv, icmp_packet->orig);if (!orig_node) - goto unlock; + goto out; -kref_get (&orig_node->refcount); +rcu_read_lock (); neigh_node = orig_node->router; - -if (!neigh_node) - goto unlock; - -if (!atomic_inc_not_zero (&neigh_node->refcount)) { +if (!neigh_node || !atomic_inc_not_zero (&neigh_node->refcount)) { neigh_node =NULL ; - goto unlock; +rcu_read_unlock (); + goto out; }rcu_read_unlock ();
@@ -112,8 +106,6 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, ret =NET_RX_SUCCESS ; goto out; -unlock: -rcu_read_unlock (); out:if (neigh_node)neigh_node_free_ref (neigh_node);
batman-adv/unicast.c +2 -12
@@ -184,15 +184,9 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, *new_skb =NULL ; -rcu_read_lock (); - orig_node = ((struct orig_node *) -hash_find (bat_priv->orig_hash, compare_orig, choose_orig, - unicast_packet->orig)); + orig_node =hash_find_orig (bat_priv, unicast_packet->orig);if (!orig_node) - goto unlock; - -kref_get (&orig_node->refcount); -rcu_read_unlock (); + goto out; orig_node->last_frag_packet = jiffies;
@@ -217,10 +211,6 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,if (*new_skb) ret =NET_RX_SUCCESS ; - goto out; - -unlock: -rcu_read_unlock (); out:if (orig_node)kref_put (&orig_node->refcount, orig_node_free_ref);
Signature · 1 line
1.7.2.3
PATCH 6/13 batman-adv: Use route_unicast_packet() for sending own unicast packets
In reply to Linus LüssingThis removes some redundancy present in unicast_send_skb(). It now invokes route_unicast_packet() for the next hop decision and sending.
--- routing.c | 15 ++++++++------- routing.h | 5 +++-- soft-interface.c | 3 ++- unicast.c | 41 +++++++---------------------------------- 4 files changed, 20 insertions(+), 44 deletions(-)
batman-adv/routing.c +8 -7
@@ -1188,10 +1188,10 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)return 0 ; } -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, -uint8_t *dest,uint8_t packet_type) +int route_unicast_packet (struct bat_priv *bat_priv,struct sk_buff *skb, +struct batman_if *recv_if,uint8_t *dest, +uint8_t packet_type) { -struct bat_priv *bat_priv =netdev_priv (recv_if->soft_iface);struct orig_node *orig_node =NULL ;struct neigh_node *neigh_node =NULL ;int ret =NET_RX_DROP ;
@@ -1252,6 +1252,7 @@ out:int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if) { +struct bat_priv *bat_priv =netdev_priv (recv_if->soft_iface);struct unicast_packet *unicast_packet;int hdr_size =sizeof (struct unicast_packet );
@@ -1266,8 +1267,8 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (skb, recv_if, unicast_packet->dest, - unicast_packet->header.packet_type); +return route_unicast_packet (bat_priv, skb, recv_if, + unicast_packet->dest, unicast_packet->header.packet_type); }int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if)
@@ -1300,8 +1301,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (skb, recv_if, unicast_packet->dest, - unicast_packet->header.packet_type); +return route_unicast_packet (bat_priv, skb, recv_if, + unicast_packet->dest, unicast_packet->header.packet_type); }
batman-adv/routing.h +3 -2
@@ -30,8 +30,9 @@ void receive_bat_packet(struct ethhdr *ethhdr,void update_routes (struct bat_priv *bat_priv,struct orig_node *orig_node,struct neigh_node *neigh_node,unsigned char *hna_buff,int hna_buff_len); -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, -uint8_t *dest,uint8_t packet_type); +int route_unicast_packet (struct bat_priv *bat_priv,struct sk_buff *skb, +struct batman_if *recv_if,uint8_t *dest, +uint8_t packet_type);int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if);
batman-adv/soft-interface.c +2 -1
@@ -482,7 +482,8 @@ void interface_rx(struct net_device *soft_iface,memcpy (unicast_packet->dest, bat_priv->softif_neigh->addr,ETH_ALEN ); - ret =route_unicast_packet (skb, recv_if, unicast_packet->dest, + ret =route_unicast_packet (bat_priv, skb, recv_if, + unicast_packet->dest, unicast_packet->header.packet_type);if (ret ==NET_RX_DROP ) goto dropped;
batman-adv/unicast.c +7 -34
65 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 7/13 batman-adv: Avoid redundant hash_find() call for own unicast packets
In reply to Linus Lüssing--- routing.c | 37 ++++++++++++++++++------------------- routing.h | 8 +++----- soft-interface.c | 6 ++++-- unicast.c | 4 ++-- 4 files changed, 27 insertions(+), 28 deletions(-)
batman-adv/routing.c +18 -19
@@ -1020,10 +1020,10 @@ out:/* find a suitable router for this originator, and use * bonding if possible. increases the found neighbors * refcount.*/ -struct neigh_node *find_router (struct bat_priv *bat_priv, -struct orig_node *orig_node, +struct neigh_node *find_router (struct orig_node *orig_node,struct batman_if *recv_if) { +struct bat_priv *bat_priv;struct orig_node *primary_orig_node;struct orig_node *router_orig;struct neigh_node *router, *first_candidate, *tmp_neigh_node;
@@ -1036,6 +1036,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,if (!orig_node->router)return NULL ; + bat_priv = orig_node->bat_priv; +/* without bonding, the first node should * always choose the default router. */ bonding_enabled =atomic_read (&bat_priv->bonding);
@@ -1188,22 +1190,15 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)return 0 ; } -int route_unicast_packet (struct bat_priv *bat_priv,struct sk_buff *skb, -struct batman_if *recv_if,uint8_t *dest, -uint8_t packet_type) +int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, +struct orig_node *orig_node,uint8_t packet_type) { -struct orig_node *orig_node =NULL ;struct neigh_node *neigh_node =NULL ;int ret =NET_RX_DROP ;struct sk_buff *new_skb; -/* get routing information */ - orig_node =hash_find_orig (bat_priv, dest); -if (!orig_node) - goto out; -/* find_router() increases neigh_nodes refcount if found. */ - neigh_node =find_router (bat_priv, orig_node, recv_if); + neigh_node =find_router (orig_node, recv_if);if (!neigh_node) goto out;
@@ -1213,9 +1208,9 @@ int route_unicast_packet(struct bat_priv *bat_priv, struct sk_buff *skb, goto out;if (packet_type ==BAT_UNICAST && -atomic_read (&bat_priv->fragmentation) && +atomic_read (&orig_node->bat_priv->fragmentation) && skb->len > neigh_node->if_incoming->net_dev->mtu) { - ret =frag_send_skb (skb, bat_priv, + ret =frag_send_skb (skb, orig_node->bat_priv, neigh_node->if_incoming, neigh_node->addr); goto out; }
@@ -1223,7 +1218,7 @@ int route_unicast_packet(struct bat_priv *bat_priv, struct sk_buff *skb,if (packet_type ==BAT_UNICAST_FRAG &&frag_can_reassemble (skb, neigh_node->if_incoming->net_dev->mtu)) { - ret =frag_reassemble_skb (skb, bat_priv, &new_skb); + ret =frag_reassemble_skb (skb, orig_node->bat_priv, &new_skb);if (ret ==NET_RX_DROP ) goto out;
@@ -1254,6 +1249,7 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) {struct bat_priv *bat_priv =netdev_priv (recv_if->soft_iface);struct unicast_packet *unicast_packet; +struct orig_node *orig_node;int hdr_size =sizeof (struct unicast_packet );if (check_unicast_packet (skb, hdr_size) <0 )
@@ -1267,14 +1263,16 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (bat_priv, skb, recv_if, - unicast_packet->dest, unicast_packet->header.packet_type); + orig_node =hash_find_orig (bat_priv, unicast_packet->dest); +return route_unicast_packet (skb, recv_if, orig_node, + unicast_packet->header.packet_type); }int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if) {struct bat_priv *bat_priv =netdev_priv (recv_if->soft_iface);struct unicast_frag_packet *unicast_packet; +struct orig_node *orig_node;int hdr_size =sizeof (struct unicast_frag_packet );struct sk_buff *new_skb =NULL ;int ret;
@@ -1301,8 +1299,9 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_SUCCESS ; } -return route_unicast_packet (bat_priv, skb, recv_if, - unicast_packet->dest, unicast_packet->header.packet_type); + orig_node =hash_find_orig (bat_priv, unicast_packet->dest); +return route_unicast_packet (skb, recv_if, orig_node, + unicast_packet->header.packet_type); }
batman-adv/routing.h +3 -5
@@ -30,17 +30,15 @@ void receive_bat_packet(struct ethhdr *ethhdr,void update_routes (struct bat_priv *bat_priv,struct orig_node *orig_node,struct neigh_node *neigh_node,unsigned char *hna_buff,int hna_buff_len); -int route_unicast_packet (struct bat_priv *bat_priv,struct sk_buff *skb, -struct batman_if *recv_if,uint8_t *dest, -uint8_t packet_type); +int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, +struct orig_node *orig_node,uint8_t packet_type);int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_bcast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_vis_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_bat_packet (struct sk_buff *skb,struct batman_if *recv_if); -struct neigh_node *find_router (struct bat_priv *bat_priv, -struct orig_node *orig_node, +struct neigh_node *find_router (struct orig_node *orig_node,struct batman_if *recv_if);void bonding_candidate_del (struct orig_node *orig_node,struct neigh_node *neigh_node);
batman-adv/soft-interface.c +4 -2
@@ -439,6 +439,7 @@ void interface_rx(struct net_device *soft_iface, {struct bat_priv *bat_priv =netdev_priv (soft_iface);struct unicast_packet *unicast_packet; +struct orig_node *orig_node;struct ethhdr *ethhdr;struct vlan_ethhdr *vhdr;short vid =-1 ;
@@ -482,8 +483,9 @@ void interface_rx(struct net_device *soft_iface,memcpy (unicast_packet->dest, bat_priv->softif_neigh->addr,ETH_ALEN ); - ret =route_unicast_packet (bat_priv, skb, recv_if, - unicast_packet->dest, + + orig_node =hash_find_orig (bat_priv, unicast_packet->dest); + ret =route_unicast_packet (skb, recv_if, orig_node, unicast_packet->header.packet_type);if (ret ==NET_RX_DROP ) goto dropped;
batman-adv/unicast.c +2 -2
@@ -308,8 +308,8 @@ route:/* copy the destination for faster routing */ memcpy (unicast_packet->dest, orig_node->orig,ETH_ALEN ); - ret =route_unicast_packet (orig_node->bat_priv, skb,NULL , - unicast_packet->dest, unicast_packet->header.packet_type); + ret =route_unicast_packet (skb,NULL , orig_node, + unicast_packet->header.packet_type); out:if (ret ==NET_RX_DROP )
Signature · 1 line
1.7.2.3
PATCH 8/13 batman-adv: Use packet lists for unicast packet sending
In reply to Linus LüssingInstead of branching the code paths and having several possible methods doing the final preparation and sending of an skb, depending on whether a packet needs to be fragmented or not, this commit now decouples the sending procedure from the fragmentation methods: The fragmentation methods are only manipulating a packet_list and packet_list_entries now so that the fragmentation process becomes transparent for route_unicast_packet().
This further allows easier integration of future extensions that send copies of multiple (modified) unicast packets to several next hop neighbours.
--- routing.c | 76 +++++++++++++++----------------------- routing.h | 4 +-- send.c | 14 +++++++ send.h | 7 ++++ soft-interface.c | 3 +- unicast.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++----- unicast.h | 25 +------------ 7 files changed, 153 insertions(+), 83 deletions(-)
batman-adv/routing.c +30 -46
@@ -1020,21 +1020,24 @@ out:/* find a suitable router for this originator, and use * bonding if possible. increases the found neighbors * refcount.*/ -struct neigh_node *find_router (struct orig_node *orig_node, -struct batman_if *recv_if) +static void find_router (struct orig_node *orig_node, +struct batman_if *recv_if, +struct sk_buff *skb, +struct hlist_head *packet_list) {struct bat_priv *bat_priv;struct orig_node *primary_orig_node;struct orig_node *router_orig;struct neigh_node *router, *first_candidate, *tmp_neigh_node; +struct packet_list_entry *entry;static uint8_t zero_mac[ETH_ALEN ] = {0 ,0 ,0 ,0 ,0 ,0 };int bonding_enabled;if (!orig_node) -return NULL ; +return ;if (!orig_node->router) -return NULL ; +return ; bat_priv = orig_node->bat_priv;
@@ -1048,7 +1051,7 @@ struct neigh_node *find_router(struct orig_node *orig_node, router_orig = orig_node->router->orig_node;if (!router_orig || !atomic_inc_not_zero (&router->refcount)) {rcu_read_unlock (); -return NULL ; +return ; }if ((!recv_if) && (!bonding_enabled))
@@ -1110,7 +1113,7 @@ struct neigh_node *find_router(struct orig_node *orig_node,if (!router) {rcu_read_unlock (); -return NULL ; +return ; }/* selected should point to the next element
@@ -1162,7 +1165,16 @@ struct neigh_node *find_router(struct orig_node *orig_node, } return_router:rcu_read_unlock (); -return router; + + entry =kmalloc (sizeof (struct packet_list_entry ),GFP_ATOMIC ); +if (!entry) { +kfree_skb (skb); +return ; + } + + entry->skb = skb; + entry->neigh_node = router; +hlist_add_head (&entry->list, packet_list); }static int check_unicast_packet (struct sk_buff *skb,int hdr_size)
@@ -1191,55 +1203,29 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size) }int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, -struct orig_node *orig_node,uint8_t packet_type) +struct orig_node *orig_node) { -struct neigh_node *neigh_node =NULL ;int ret =NET_RX_DROP ; -struct sk_buff *new_skb; +struct hlist_head packet_list; -/* find_router() increases neigh_nodes refcount if found. */ - neigh_node =find_router (orig_node, recv_if); - -if (!neigh_node) - goto out; +INIT_HLIST_HEAD (&packet_list);/* create a copy of the skb, if needed, to modify it. */ if (skb_cow (skb,sizeof (struct ethhdr )) <0 ) goto out; -if (packet_type ==BAT_UNICAST && -atomic_read (&orig_node->bat_priv->fragmentation) && - skb->len > neigh_node->if_incoming->net_dev->mtu) { - ret =frag_send_skb (skb, orig_node->bat_priv, - neigh_node->if_incoming, neigh_node->addr); - goto out; - } +/* creates the (initial) packet list */ +find_router (orig_node, recv_if, skb, &packet_list); -if (packet_type ==BAT_UNICAST_FRAG && -frag_can_reassemble (skb, neigh_node->if_incoming->net_dev->mtu)) { +/* split packets that won't fit or maybe buffer fragments */ +frag_packet_list (orig_node->bat_priv, &packet_list); - ret =frag_reassemble_skb (skb, orig_node->bat_priv, &new_skb); - -if (ret ==NET_RX_DROP ) - goto out; - -/* packet was buffered for late merge */ -if (!new_skb) { - ret =NET_RX_SUCCESS ; - goto out; - } - - skb = new_skb; - } - -/* route it */ -send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); +/* route them */ +send_packet_list (&packet_list); ret =NET_RX_SUCCESS ; goto out; out: -if (neigh_node) -neigh_node_free_ref (neigh_node);if (orig_node)kref_put (&orig_node->refcount, orig_node_free_ref);return ret;
@@ -1264,8 +1250,7 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) } orig_node =hash_find_orig (bat_priv, unicast_packet->dest); -return route_unicast_packet (skb, recv_if, orig_node, - unicast_packet->header.packet_type); +return route_unicast_packet (skb, recv_if, orig_node); }int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if)
@@ -1300,8 +1285,7 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if) } orig_node =hash_find_orig (bat_priv, unicast_packet->dest); -return route_unicast_packet (skb, recv_if, orig_node, - unicast_packet->header.packet_type); +return route_unicast_packet (skb, recv_if, orig_node); }
batman-adv/routing.h +1 -3
@@ -31,15 +31,13 @@ void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, struct neigh_node *neigh_node, unsigned char *hna_buff, int hna_buff_len);int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, -struct orig_node *orig_node,uint8_t packet_type); +struct orig_node *orig_node);int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_bcast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_vis_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_bat_packet (struct sk_buff *skb,struct batman_if *recv_if); -struct neigh_node *find_router (struct orig_node *orig_node, -struct batman_if *recv_if);void bonding_candidate_del (struct orig_node *orig_node,struct neigh_node *neigh_node);
batman-adv/send.c +14 -0
@@ -196,6 +196,20 @@ send_skb_err:return NET_XMIT_DROP ; } +void send_packet_list (struct hlist_head *packet_list) +{ +struct packet_list_entry *entry; +struct hlist_node *pos, *tmp; + +hlist_for_each_entry_safe (entry, pos, tmp, packet_list, list) { +send_skb_packet (entry->skb, entry->neigh_node->if_incoming, + entry->neigh_node->addr); +neigh_node_free_ref (entry->neigh_node); +hlist_del (&entry->list); +kfree (entry); + } +} +/* Send a packet to a given interface */ static void send_packet_to_if (struct forw_packet *forw_packet,struct batman_if *batman_if)
batman-adv/send.h +7 -0
@@ -22,9 +22,16 @@#ifndef _NET_BATMAN_ADV_SEND_H_#define _NET_BATMAN_ADV_SEND_H_ +struct packet_list_entry { +struct hlist_node list; +struct sk_buff *skb; +struct neigh_node *neigh_node; +}; +int send_skb_packet (struct sk_buff *skb,struct batman_if *batman_if,uint8_t *dst_addr); +void send_packet_list (struct hlist_head *packet_list);void schedule_own_packet (struct batman_if *batman_if); void schedule_forward_packet(struct orig_node *orig_node, struct ethhdr *ethhdr,
batman-adv/soft-interface.c +1 -2
@@ -485,8 +485,7 @@ void interface_rx(struct net_device *soft_iface, bat_priv->softif_neigh->addr, ETH_ALEN); orig_node =hash_find_orig (bat_priv, unicast_packet->dest); - ret =route_unicast_packet (skb, recv_if, orig_node, - unicast_packet->header.packet_type); + ret =route_unicast_packet (skb, recv_if, orig_node);if (ret ==NET_RX_DROP ) goto dropped;
batman-adv/unicast.c +98 -9
138 lines not on this page · raw message
batman-adv/unicast.h +2 -23
@@ -30,29 +30,8 @@int frag_reassemble_skb (struct sk_buff *skb,struct bat_priv *bat_priv,struct sk_buff **new_skb);void frag_list_free (struct list_head *head); +void frag_packet_list (struct bat_priv *bat_priv, +struct hlist_head *packet_list);int unicast_send_skb (struct sk_buff *skb,struct bat_priv *bat_priv); -int frag_send_skb (struct sk_buff *skb,struct bat_priv *bat_priv, -struct batman_if *batman_if,uint8_t dstaddr[]); - -static inline int frag_can_reassemble (struct sk_buff *skb,int mtu) -{ -struct unicast_frag_packet *unicast_packet; -int uneven_correction =0 ; -unsigned int merged_size; - - unicast_packet = (struct unicast_frag_packet *)skb->data; - -if (unicast_packet->flags &UNI_FRAG_LARGETAIL ) { -if (unicast_packet->flags &UNI_FRAG_HEAD ) - uneven_correction =1 ; -else - uneven_correction =-1 ; - } - - merged_size = (skb->len -sizeof (struct unicast_frag_packet )) *2 ; - merged_size +=sizeof (struct unicast_packet ) + uneven_correction; - -return merged_size <= mtu; -}#endif /* _NET_BATMAN_ADV_UNICAST_H_ */
Signature · 1 line
1.7.2.3
PATCH 9/13 batman-adv: Add sysfs option for enabling redundant bonding mode
In reply to Linus LüssingWhen bonding is enabled, then enabling red_bonding too changes the behavior from throughput bonding (round robin sending on interfaces) to redundant bonding (sending every packet on all interfaces available for bonding).
--- bat_sysfs.c | 10 ++++++++++ soft-interface.c | 1 + types.h | 1 + 3 files changed, 12 insertions(+), 0 deletions(-)
batman-adv/bat_sysfs.c +10 -0
@@ -356,8 +356,17 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,return gw_bandwidth_set (net_dev, buff, count); } +static void print_bonding_notice (struct net_device *net_dev) +{ +bat_info (net_dev,"Redundant Bonding mode is currently not compatible " +"with batman-adv's link layer fragmentation and will " +"be ignored. Also make sure to activate general " +"bonding for redundant bonding to take effect.\n" ); +} +BAT_ATTR_BOOL (aggregated_ogms,S_IRUGO |S_IWUSR ,NULL );BAT_ATTR_BOOL (bonding,S_IRUGO |S_IWUSR ,NULL ); +BAT_ATTR_BOOL (red_bonding,S_IRUGO |S_IWUSR , print_bonding_notice);BAT_ATTR_BOOL (fragmentation,S_IRUGO |S_IWUSR , update_min_mtu); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
@@ -374,6 +383,7 @@ BAT_ATTR_UINT(log_level, S_IRUGO | S_IWUSR, 0, 3, NULL);static struct bat_attribute *mesh_attrs[] = { &bat_attr_aggregated_ogms, &bat_attr_bonding, + &bat_attr_red_bonding, &bat_attr_fragmentation, &bat_attr_vis_mode, &bat_attr_gw_mode,
batman-adv/soft-interface.c +1 -0
@@ -590,6 +590,7 @@ struct net_device *softif_create(char *name)atomic_set (&bat_priv->aggregated_ogms,1 );atomic_set (&bat_priv->bonding,0 ); +atomic_set (&bat_priv->red_bonding,0 );atomic_set (&bat_priv->vis_mode,VIS_TYPE_CLIENT_UPDATE );atomic_set (&bat_priv->gw_mode,GW_MODE_OFF );atomic_set (&bat_priv->gw_sel_class,20 );
batman-adv/types.h +1 -0
@@ -131,6 +131,7 @@ struct bat_priv {struct net_device_stats stats;atomic_t aggregated_ogms;/* boolean */ atomic_t bonding;/* boolean */ +atomic_t red_bonding;/* boolean */ atomic_t fragmentation;/* boolean */ atomic_t vis_mode;/* VIS_TYPE_* */ atomic_t gw_mode;/* GW_MODE_* */
Signature · 1 line
1.7.2.3
PATCH 10/13 batman-adv: Adding redundant bonding mode transmission
In reply to Linus LüssingWith this feature unicast packets can be send in a redundancy bonding instead of throughput bonding mode on all interfaces available towards a common node. This shall increase the robustness of unicast data transfer / decrease packet loss in cases where bursty packet loss on only one channel, which batman-adv's link quality measurements cannot detect, is to be expected or where batman-adv's metric adaptation is expected to be too slow for certain scenarios.
--- main.h | 5 ++ packet.h | 8 ++++ routing.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++----- routing.h | 3 +- soft-interface.c | 8 +++- types.h | 1 + unicast.c | 10 +++-- unicast.h | 2 +- 8 files changed, 135 insertions(+), 19 deletions(-)
batman-adv/main.h +5 -0
@@ -97,6 +97,11 @@* Vis */ +/* Bonding modes */ +#define THROUGHPUT_BONDING 1 +#define REDUNDANT_BONDING 2 + +/* * Kernel headers */
batman-adv/packet.h +8 -0
@@ -30,6 +30,7 @@#define BAT_BCAST 0x04#define BAT_VIS 0x05#define BAT_UNICAST_FRAG 0x06 +#define BAT_UNICAST_SAFE 0x07/* this file is included by batctl which needs these defines */ #define COMPAT_VERSION 12
@@ -101,6 +102,13 @@ struct unicast_packet {uint8_t dest[6 ]; } __packed; +struct unicast_packet_safe { +struct batman_header header; +uint8_t dest[6 ]; +uint8_t orig[6 ]; +uint32_t seqno; +} __packed; +struct unicast_frag_packet {struct batman_header header;uint8_t dest[6 ];
batman-adv/routing.c +106 -11
201 lines not on this page · raw message
batman-adv/routing.h +2 -1
@@ -30,7 +30,8 @@ void receive_bat_packet(struct ethhdr *ethhdr,void update_routes (struct bat_priv *bat_priv,struct orig_node *orig_node,struct neigh_node *neigh_node,unsigned char *hna_buff,int hna_buff_len); -int route_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if, +int route_unicast_packet (int bonding_mode,struct sk_buff *skb, +struct batman_if *recv_if,struct orig_node *orig_node);int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);
batman-adv/soft-interface.c +6 -2
@@ -443,7 +443,7 @@ void interface_rx(struct net_device *soft_iface,struct ethhdr *ethhdr;struct vlan_ethhdr *vhdr;short vid =-1 ; -int ret; +int ret, bonding_mode;/* check if enough space is available for pulling, and pull */ if (!pskb_may_pull (skb, hdr_size))
@@ -484,8 +484,11 @@ void interface_rx(struct net_device *soft_iface,memcpy (unicast_packet->dest, bat_priv->softif_neigh->addr,ETH_ALEN ); + bonding_mode =atomic_read (&bat_priv->bonding) << +atomic_read (&bat_priv->red_bonding); orig_node =hash_find_orig (bat_priv, unicast_packet->dest); - ret =route_unicast_packet (skb, recv_if, orig_node); + ret =route_unicast_packet (bonding_mode, skb, recv_if, + orig_node);if (ret ==NET_RX_DROP ) goto dropped;
@@ -604,6 +607,7 @@ struct net_device *softif_create(char *name)atomic_set (&bat_priv->mesh_state,MESH_INACTIVE );atomic_set (&bat_priv->bcast_seqno,1 ); +atomic_set (&bat_priv->dup_seqno,1 );atomic_set (&bat_priv->hna_local_changed,0 ); bat_priv->primary_if =NULL ;
batman-adv/types.h +1 -0
@@ -141,6 +141,7 @@ struct bat_priv {atomic_t hop_penalty;/* uint */ atomic_t log_level;/* uint */ atomic_t bcast_seqno; +atomic_t dup_seqno;atomic_t bcast_queue_left;atomic_t batman_queue_left;char num_ifaces;
batman-adv/unicast.c +6 -4
@@ -30,7 +30,6 @@#include "routing.h" #include "hard-interface.h" -static struct sk_buff *frag_merge_packet (struct list_head *head,struct frag_packet_list_entry *tfp,struct sk_buff *skb)
@@ -333,7 +332,7 @@ static inline int frag_can_reassemble(struct sk_buff *skb, int mtu)return merged_size <= mtu; } -void frag_packet_list (struct bat_priv *bat_priv, +void frag_packet_list (int bonding,struct bat_priv *bat_priv,struct hlist_head *packet_list) {struct packet_list_entry *entry;
@@ -347,6 +346,7 @@ void frag_packet_list(struct bat_priv *bat_priv,switch (packet_type) {case BAT_UNICAST :if (!atomic_read (&bat_priv->fragmentation) || + bonding ==REDUNDANT_BONDING || entry->skb->len <= entry->neigh_node->if_incoming->net_dev->mtu)break ;
@@ -372,7 +372,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)struct ethhdr *ethhdr = (struct ethhdr *)skb->data;struct unicast_packet *unicast_packet;struct orig_node *orig_node; -int ret =NET_RX_DROP ; +int ret =NET_RX_DROP , bonding_mode;/* get routing information */ if (is_multicast_ether_addr (ethhdr->h_dest)) {
@@ -398,7 +398,9 @@ route:/* copy the destination for faster routing */ memcpy (unicast_packet->dest, orig_node->orig,ETH_ALEN ); - ret =route_unicast_packet (skb,NULL , orig_node); + bonding_mode =atomic_read (&bat_priv->bonding) << +atomic_read (&bat_priv->red_bonding); + ret =route_unicast_packet (bonding_mode, skb,NULL , orig_node); out:if (ret ==NET_RX_DROP )
batman-adv/unicast.h +1 -1
@@ -30,7 +30,7 @@int frag_reassemble_skb (struct sk_buff *skb,struct bat_priv *bat_priv,struct sk_buff **new_skb);void frag_list_free (struct list_head *head); -void frag_packet_list (struct bat_priv *bat_priv, +void frag_packet_list (int bonding,struct bat_priv *bat_priv,struct hlist_head *packet_list);int unicast_send_skb (struct sk_buff *skb,struct bat_priv *bat_priv);
Signature · 1 line
1.7.2.3
PATCH 11/13 batman-adv: Adding unicast_safe packet reception
In reply to Linus LüssingWith this commit unicast_safe packets generated by a node in redundant bonding mode will be processed on reception. It is being transformed back to a normal unicast packet if the packet is for the node itself or if redundant bonding mode is deactivated on this node. Otherwise it is being passed on as is to the routing functions.
--- hard-interface.c | 5 ++++ routing.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++--- routing.h | 1 + 3 files changed, 62 insertions(+), 4 deletions(-)
batman-adv/hard-interface.c +5 -0
@@ -623,6 +623,11 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ret =recv_ucast_frag_packet (skb, batman_if);break ; +/* fragmented unicast packet */ +case BAT_UNICAST_SAFE : + ret =recv_ucast_safe_packet (skb, batman_if); +break ; +/* broadcast packet */ case BAT_BCAST : ret =recv_bcast_packet (skb, batman_if);
batman-adv/routing.c +56 -4
78 lines not on this page · raw message
batman-adv/routing.h +1 -0
@@ -36,6 +36,7 @@ int route_unicast_packet(int bonding_mode, struct sk_buff *skb,int recv_icmp_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_unicast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_ucast_frag_packet (struct sk_buff *skb,struct batman_if *recv_if); +int recv_ucast_safe_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_bcast_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_vis_packet (struct sk_buff *skb,struct batman_if *recv_if);int recv_bat_packet (struct sk_buff *skb,struct batman_if *recv_if);
Signature · 1 line
1.7.2.3
PATCH 12/13 batman-adv: Generic sequence number checking for data packets
In reply to Linus LüssingThis reduces the size of recv_bcast_packet, increasing its readability. It further introduces a generic function for duplicate checking for data packets (which might later be used for multicast or promiscous unicast packet handling or other packets).
--- originator.c | 2 +- routing.c | 60 ++++++++++++++++++++++++++++++++++----------------------- types.h | 10 ++++++-- 3 files changed, 44 insertions(+), 28 deletions(-)
batman-adv/originator.c +1 -1
@@ -211,7 +211,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ; orig_node->hna_buff =NULL ; - orig_node->bcast_seqno_reset = jiffies -1 + orig_node->bcast_seqno_state.seqno_reset = jiffies -1 -msecs_to_jiffies (RESET_PROTECTION_MS ); orig_node->batman_seqno_reset = jiffies -1 -msecs_to_jiffies (RESET_PROTECTION_MS );
batman-adv/routing.c +36 -24
86 lines not on this page · raw message
batman-adv/types.h +7 -3
@@ -49,6 +49,12 @@ struct batman_if {struct rcu_head rcu; }; +struct seqno_state { +unsigned long seqno_reset; +uint32_t last_seqno; +unsigned long bits[NUM_WORDS ]; +}; +/** * orig_node - structure for orig_list maintaining nodes of mesh * @primary_addr: hosts primary interface address
@@ -71,7 +77,6 @@ struct orig_node {unsigned long *bcast_own;uint8_t *bcast_own_sum;unsigned long last_valid; -unsigned long bcast_seqno_reset;unsigned long batman_seqno_reset;uint8_t gw_flags;uint8_t flags;
@@ -79,14 +84,13 @@ struct orig_node {int16_t hna_buff_len;uint32_t last_real_seqno;uint8_t last_ttl; -unsigned long bcast_bits[NUM_WORDS ]; -uint32_t last_bcast_seqno;struct hlist_head neigh_list;struct list_head frag_list;spinlock_t neigh_list_lock;/* protects neighbor list */ struct kref refcount;struct bat_priv *bat_priv;unsigned long last_frag_packet; +struct seqno_state bcast_seqno_state;spinlock_t ogm_cnt_lock;/* protects: bcast_own, bcast_own_sum, * neigh_node->real_bits, * neigh_node->real_packet_count */
Signature · 1 line
1.7.2.3
PATCH 13/13 batman-adv: Add sequence number and duplicate checks for unicasts_safe
In reply to Linus LüssingWith the new redundant bonding mode a node might receive a unicast_safe packet more than once. Therefore duplicate checks on any unicast_safe packet need to be performed before further processing.
--- originator.c | 3 +++ routing.c | 14 +++++++++++++- types.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletions(-)
batman-adv/originator.c +3 -0
@@ -204,6 +204,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)INIT_LIST_HEAD (&orig_node->bond_list);spin_lock_init (&orig_node->ogm_cnt_lock);spin_lock_init (&orig_node->bcast_seqno_lock); +spin_lock_init (&orig_node->ucast_safe_seqno_lock);spin_lock_init (&orig_node->neigh_list_lock);kref_init (&orig_node->refcount);
@@ -213,6 +214,8 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) orig_node->hna_buff =NULL ; orig_node->bcast_seqno_state.seqno_reset = jiffies -1 -msecs_to_jiffies (RESET_PROTECTION_MS ); + orig_node->ucast_safe_seqno_state.seqno_reset = jiffies -1 + -msecs_to_jiffies (RESET_PROTECTION_MS ); orig_node->batman_seqno_reset = jiffies -1 -msecs_to_jiffies (RESET_PROTECTION_MS );
batman-adv/routing.c +13 -1
@@ -1439,13 +1439,25 @@ int recv_ucast_safe_packet(struct sk_buff *skb, struct batman_if *recv_if)struct unicast_packet_safe *unicast_packet;struct orig_node *orig_node;int hdr_size =sizeof (struct unicast_packet ); -int bonding_mode; +int ret, bonding_mode;if (check_unicast_packet (skb, hdr_size) <0 )return NET_RX_DROP ; unicast_packet = (struct unicast_packet_safe *)skb->data; + orig_node =hash_find_orig (bat_priv, unicast_packet->orig); +if (!orig_node) +return NET_RX_DROP ; + + ret =check_duplicate (bat_priv,ntohl (unicast_packet->seqno), + &orig_node->ucast_safe_seqno_state, + &orig_node->ucast_safe_seqno_lock); + +kref_put (&orig_node->refcount, orig_node_free_ref); +if (ret ==NET_RX_DROP ) +return NET_RX_DROP ; +/* packet for me */ if (is_my_mac (unicast_packet->dest)) {unicast_safe_to_unicast (skb);
batman-adv/types.h +2 -0
@@ -91,11 +91,13 @@ struct orig_node {struct bat_priv *bat_priv;unsigned long last_frag_packet;struct seqno_state bcast_seqno_state; +struct seqno_state ucast_safe_seqno_state;spinlock_t ogm_cnt_lock;/* protects: bcast_own, bcast_own_sum, * neigh_node->real_bits, * neigh_node->real_packet_count */ spinlock_t bcast_seqno_lock;/* protects bcast_bits, * last_bcast_seqno */ +spinlock_t ucast_safe_seqno_lock;/* protects ucast_safe_seqno_state */ atomic_t bond_candidates;struct list_head bond_list; };
Signature · 1 line
1.7.2.3
Re: [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman header structure
In reply to Linus LüssingQuoted 3 lines · Linus L??ssing
Just a minor style adjustment, to give people a hint which fields should not be reordered and need to be at the beginning of each packet with batman-adv's frame type.
Hi Linus
Quoted 12 lines
batman-adv/packet.h +9
-2+struct batman_header { +uint8_t packet_type; +uint8_t version;/* batman version field */ +uint8_t ttl; +uint8_t align; +} __packed; +struct batman_packet { -uint8_t packet_type; -uint8_t version;/* batman version field */ +struct batman_header header; +uint32_t seqno;
batman-adv/packet.h line 71
Quoted 10 lines
batman-adv/packet.h +0
-3uint8_t flags;/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ uint8_t tq; -uint32_t seqno;uint8_t orig[6 ];uint8_t prev_sender[6 ]; -uint8_t ttl;uint8_t num_hna;uint8_t gw_flags;/* flags related to gateway class */ -uint8_t align; } __packed;
Two different ideas, both triggered by the align byte in header. This byte is a waste of space, it is not used, and it is probably not easy to find something which all packet types are going to need in the future.
1) Did you try not having it. So long header is __packed, and all the structures it is used in are __packed, i think the compiler will do the right thing. The downside is that alignment is not obvious. Most people will assume header is 4 bytes, not 3, and think the alignment of the packets is wrong.
2) Did you consider using a union? It is a more invasive patch, but the alignment is then clear. The downside is sizeof() no longer gives you the per packet type size, rather it gives you the size of the biggest member of the union. So this makes the change even more invasive and bug prone.
I think i prefer 1), with appropriate comments to explain the alignment issue.
Andrew
Re: [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: Unify TTL handling
In reply to Linus Lüssingbatman-adv/send.c static unsigned long forward_send_time(void) · line 64
Quoted 12 lines · Linus L??ssing
All our packets have a TTL and with the last batman header patch also at the same place in a batman encapsulated packet. We can therefore savely do one single TTL check before sending any batman packet type.
batman-adv/send.c +8
-0+static int recv_icmp_ttl_exceeded (struct bat_priv *bat_priv, +struct sk_buff *skb) +{ +struct orig_node *orig_node =NULL ; +struct neigh_node *neigh_node =NULL ; +struct icmp_packet *icmp_packet; +int ret =NET_RX_DROP ; +
This is in the middle of the send path, so calling it recv_icmp_ttl_exceeded() seems a bit strange. I would say either send_icmp_ttl_exceeded() or recvd_icmp_ttl_exceeded() are better.
Andrew
Re: [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: Unify TTL handling
Andrew Lunn <[email protected]> schrieb am 16.02.2011 07:16:49:
Quoted 10 lines
[Bild entfernt]
Re: [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: Unify TTL handling
Andrew Lunn
an:
The list for a Better Approach To Mobile Ad-hoc Networking
Quoted 8 lines
16.02.2011 07:17
Kopie:
Linus L??ssing
Quoted 1 line · Linus L??ssing
All our packets have a TTL and with the last batman header patch also
at
Quoted 1 line
Quoted 1 line
the same place in a batman encapsulated packet. We can therefore
savely
Quoted 15 lines
batman-adv/send.c static unsigned long forward_send_time(void) · line 64
Quoted 10 lines
do one single TTL check before sending any batman packet type.
batman-adv/send.c +8
-0+static int recv_icmp_ttl_exceeded (struct bat_priv *bat_priv, +struct sk_buff *skb) +{ +struct orig_node *orig_node =NULL ; +struct neigh_node *neigh_node =NULL ; +struct icmp_packet *icmp_packet; +int ret =NET_RX_DROP ; +This is in the middle of the send path, so calling it
recv_icmp_ttl_exceeded()seems a bit strange. I would say eithersend_icmp_ttl_exceeded()orrecvd_icmp_ttl_exceeded()are better.
Quoted 1 line
Andrew
Ah, yes, you're right, I missed that when I just moved the function. the recv_ naming does not make sense here anymore, correct, I'll change that.
Re: [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman header structure
In reply to Andrew LunnAndrew Lunn <[email protected]> schrieb am 16.02.2011 07:08:11:
Quoted 11 lines
[Bild entfernt]
Re: [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman header structure
Andrew Lunn
an:
The list for a Better Approach To Mobile Ad-hoc Networking
Quoted 8 lines
16.02.2011 07:08
Kopie:
Linus L??ssing
Quoted 1 line · Linus L??ssing
Just a minor style adjustment, to give people a hint which fields
should
Quoted 5 lines
Quoted 2 lines
not be reordered and need to be at the beginning of each packet with batman-adv's frame type.
Hi Linus
Quoted 13 lines
batman-adv/packet.h
Quoted 13 lines
batman-adv/packet.h +9
-2+struct batman_header { +uint8_t packet_type; +uint8_t version;/* batman version field */ +uint8_t ttl; +uint8_t align; +} __packed; +struct batman_packet { -uint8_t packet_type; -uint8_t version;/* batman version field */ +struct batman_header header; +uint32_t seqno;uint8_t flags;/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER
flag... */
Quoted 10 lines
batman-adv/packet.h line 71
Quoted 9 lines
uint8_t tq;batman-adv/packet.h +0
-3-uint32_t seqno;uint8_t orig[6 ];uint8_t prev_sender[6 ]; -uint8_t ttl;uint8_t num_hna;uint8_t gw_flags;/* flags related to gateway class */ -uint8_t align; } __packed;
Quoted 4 lines
Two different ideas, both triggered by the align byte in header. This byte is a waste of space, it is not used, and it is probably not easy to find something which all packet types are going to need in the future.
Sure, anything that not all packet types have in common can't go inside of the batman_header. But are those three variables something we could agree on, being something that all packet types will need today and in the future?
version + packet_type is something we'll always need I think, the TTL might
be something to argue about, as packets that do not get routed would not necessarily need them (though it could be a "safety belt" in case of bugs, to really make sure packets only intended for one hop will not be routed).
Quoted 7 lines
1) Did you try not having it. So long header is
__packed, and all the structures it is used in are__packed, i think the compiler will do the right thing. The downside is that alignment is not obvious. Most people will assume header is 4 bytes, not 3, and think the alignment of the packets is wrong.
Quoted 5 lines
2) Did you consider using a union? It is a more invasive patch, but the alignment is then clear. The downside is
sizeof()no longer gives you the per packet type size, rather it gives you the size of the biggest member of the union. So this makes the change even more invasive and bug prone.
Hmm, no, actually haven't thought about that. So we'd actually put the batman
packet types as a union inside of the batman-header structure, instead of putting the header structure at the front of each packet type. Don't know if I'd like that either, due to the reason you've mentioned.
Quoted 3 lines
I think i prefer 1), with appropriate comments to explain the alignment issue.
So I think I'd prefer the first option, that should work too :). Just didn't think
that an extra Byte would matter that much, and had the readability / making the
alignment a little more obvious in mind. (And who knows when we might need to increase
the version number size already ;) )
Quoted 2 lines
Andrew
Cheers, Linus