TVLV infrastructure (v2)
Hi,
at the battlemesh we had plenty of time to discuss and test the tvlv patchset. Therefore, a number of changes/fixes found their way into v2 touching the tvlv API, network coding, unicast sending and gateway announcements.
This looks like the final version which is going to be merged unless objections are raised soon-ish.
Cheers,
Marek
PATCH v2 1/7 batman-adv: tvlv - basic infrastructure
The goal is to provide the infrastructure for sending, receiving and parsing information 'containers' while preserving backward compatibility. TVLV (based on the commonly known Type Length Value technique) was chosen as the format for those containers. Even if a node does not know the tvlv type of a certain container it can simply skip the current container and proceed with the next. Past experience has shown features evolve over time, so a 'version' field was added right from the start to allow differentiating between feature variants - hence the name: T(ype) V(ersion) L(ength) V(alue).
This patch introduces the basic TVLV infrastructure:
* register / unregister tvlv containers to be sent with each OGM (on primary interfaces only)
* register / unregister callback handlers to be called upon finding the corresponding tvlv type in a tvlv buffer
* unicast tvlv send / receive API calls
--- bat_iv_ogm.c | 38 ++-- compat.c | 8 + compat.h | 1 + main.c | 620 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.h | 35 ++++ packet.h | 67 +++++++ routing.c | 48 +++++ routing.h | 2 + types.h | 73 +++++++ 9 files changed, 875 insertions(+), 17 deletions(-)
bat_iv_ogm.c +21 -17
@@ -190,12 +190,12 @@ static uint8_t batadv_hop_penalty(uint8_t tq,/* is there another aggregated packet here? */ static int batadv_iv_ogm_aggr_packet (int buff_pos,int packet_len, -int tt_num_changes) +__be16 tvlv_len) {int next_buff_pos =0 ; next_buff_pos += buff_pos +BATADV_OGM_HLEN ; - next_buff_pos +=batadv_tt_len (tt_num_changes); + next_buff_pos +=ntohs (tvlv_len);return (next_buff_pos <= packet_len) && (next_buff_pos <=BATADV_MAX_AGGREGATION_BYTES );
@@ -223,7 +223,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,/* adjust all flags and log packets */ while (batadv_iv_ogm_aggr_packet (buff_pos, forw_packet->packet_len, - batadv_ogm_packet->tt_num_changes)) { + batadv_ogm_packet->tvlv_len)) {/* we might have aggregated direct link packets with an * ordinary base packet */
@@ -250,7 +250,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet, hard_iface->net_dev->dev_addr); buff_pos +=BATADV_OGM_HLEN ; - buff_pos +=batadv_tt_len (batadv_ogm_packet->tt_num_changes); + buff_pos +=ntohs (batadv_ogm_packet->tvlv_len); packet_num++; packet_pos = forw_packet->skb->data + buff_pos; batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
@@ -583,7 +583,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node, struct batadv_hard_iface *if_incoming) {struct batadv_priv *bat_priv =netdev_priv (if_incoming->soft_iface); -uint8_t tt_num_changes; +uint16_t tvlv_len;if (batadv_ogm_packet->header.ttl <=1 ) {batadv_dbg (BATADV_DBG_BATMAN , bat_priv,"ttl exceeded\n" );
@@ -603,7 +603,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,return ; } - tt_num_changes = batadv_ogm_packet->tt_num_changes; + tvlv_len =ntohs (batadv_ogm_packet->tvlv_len); batadv_ogm_packet->header.ttl--;memcpy (batadv_ogm_packet->prev_sender, ethhdr->h_source,ETH_ALEN );
@@ -624,7 +624,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node, batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK ;batadv_iv_ogm_queue_add (bat_priv, (unsigned char *)batadv_ogm_packet, -BATADV_OGM_HLEN +batadv_tt_len (tt_num_changes), +BATADV_OGM_HLEN + tvlv_len, if_incoming,0 ,batadv_iv_ogm_fwd_send_time ()); }
@@ -673,16 +673,18 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)int vis_server, tt_num_changes =0 ;uint32_t seqno;uint8_t bandwidth; +uint16_t tvlv_len =0 ; vis_server =atomic_read (&bat_priv->vis_mode); primary_if =batadv_primary_if_get_selected (bat_priv);if (hard_iface == primary_if) - tt_num_changes =batadv_tt_append_diff (bat_priv, ogm_buff, - ogm_buff_len, -BATADV_OGM_HLEN ); + tvlv_len =batadv_tvlv_container_ogm_append (bat_priv, ogm_buff, + ogm_buff_len, +BATADV_OGM_HLEN ); batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff); + batadv_ogm_packet->tvlv_len =htons (tvlv_len);/* change sequence number to network order */ seqno = (uint32_t )atomic_read (&hard_iface->bat_iv.ogm_seqno);
@@ -1228,6 +1230,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, goto out; } +batadv_tvlv_ogm_receive (bat_priv, batadv_ogm_packet, orig_node); +/* if sender is a direct neighbor the sender mac equals * originator mac */
@@ -1323,9 +1327,9 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,struct batadv_ogm_packet *batadv_ogm_packet;struct ethhdr *ethhdr;int buff_pos =0 , packet_len; -unsigned char *tt_buff, *packet_buff; -bool ret; +unsigned char *tvlv_buff, *packet_buff;uint8_t *packet_pos; +bool ret; ret =batadv_check_management_packet (skb, if_incoming,BATADV_OGM_HLEN );if (!ret)
@@ -1348,14 +1352,14 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,/* unpack the aggregated packets and process them one by one */ while (batadv_iv_ogm_aggr_packet (buff_pos, packet_len, - batadv_ogm_packet->tt_num_changes)) { - tt_buff = packet_buff + buff_pos +BATADV_OGM_HLEN ; + batadv_ogm_packet->tvlv_len)) { + tvlv_buff = packet_buff + buff_pos +BATADV_OGM_HLEN ; -batadv_iv_ogm_process (ethhdr, batadv_ogm_packet, tt_buff, - if_incoming); +batadv_iv_ogm_process (ethhdr, batadv_ogm_packet, + tvlv_buff, if_incoming); buff_pos +=BATADV_OGM_HLEN ; - buff_pos +=batadv_tt_len (batadv_ogm_packet->tt_num_changes); + buff_pos +=ntohs (batadv_ogm_packet->tvlv_len); packet_pos = packet_buff + buff_pos; batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
compat.c +8 -0
@@ -84,4 +84,12 @@ void batadv_free_rcu_nc_path(struct rcu_head *rcu) }#endif +void batadv_free_rcu_tvlv_handler (struct rcu_head *rcu) +{ +struct batadv_tvlv_handler *tvlv_handler; + + tvlv_handler = container_of(rcu, struct batadv_tvlv_handler, rcu); +kfree (tvlv_handler); +} +#endif /* < KERNEL_VERSION(3, 0, 0) */
compat.h +1 -0
@@ -188,6 +188,7 @@ void batadv_free_rcu_tt_local_entry(struct rcu_head *rcu);void batadv_free_rcu_backbone_gw (struct rcu_head *rcu);void batadv_free_rcu_dat_entry (struct rcu_head *rcu);void batadv_free_rcu_nc_path (struct rcu_head *rcu); +void batadv_free_rcu_tvlv_handler (struct rcu_head *rcu);static inline void skb_reset_mac_len (struct sk_buff *skb) {
main.c +620 -0
650 lines not on this page · raw message
main.h +35 -0
@@ -329,4 +329,39 @@ static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv,*/ #define BATADV_SKB_CB (__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0])) +void batadv_tvlv_container_register (struct batadv_priv *bat_priv, +uint8_t type,uint8_t version, +void *tvlv_value,uint16_t tvlv_value_len); +uint16_t batadv_tvlv_container_ogm_append (struct batadv_priv *bat_priv, +unsigned char **packet_buff, +int *packet_buff_len, +int packet_min_len); +void batadv_tvlv_ogm_receive (struct batadv_priv *bat_priv, +struct batadv_ogm_packet *batadv_ogm_packet, +struct batadv_orig_node *orig_node); +void batadv_tvlv_container_unregister (struct batadv_priv *bat_priv, +uint8_t type,uint8_t version); + +void batadv_tvlv_handler_register (struct batadv_priv *bat_priv, +void (*optr)(struct batadv_priv *bat_priv, +struct batadv_orig_node *orig, +uint8_t flags, +void *tvlv_value, +uint16_t tvlv_value_len), +int (*uptr)(struct batadv_priv *bat_priv, +uint8_t *src,uint8_t *dst, +void *tvlv_value, +uint16_t tvlv_value_len), +uint8_t type,uint8_t version,uint8_t flags); +void batadv_tvlv_handler_unregister (struct batadv_priv *bat_priv, +uint8_t type,uint8_t version); +int batadv_tvlv_containers_process (struct batadv_priv *bat_priv, +bool ogm_source, +struct batadv_orig_node *orig_node, +uint8_t *src,uint8_t *dst, +void *tvlv_buff,uint16_t tvlv_buff_len); +void batadv_tvlv_unicast_send (struct batadv_priv *bat_priv,uint8_t *src, +uint8_t *dst,uint8_t type,uint8_t version, +void *tvlv_value,uint16_t tvlv_value_len); +#endif /* _NET_BATMAN_ADV_MAIN_H_ */
packet.h +67 -0
95 lines not on this page · raw message
routing.c +48 -0
54 lines not on this page · raw message
routing.h +2 -0
@@ -40,6 +40,8 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if);int batadv_recv_roam_adv (struct sk_buff *skb,struct batadv_hard_iface *recv_if); +int batadv_recv_unicast_tvlv (struct sk_buff *skb, +struct batadv_hard_iface *recv_if);struct batadv_neigh_node * batadv_find_router(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node,
types.h +73 -0
95 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 2/7 batman-adv: tvlv - gateway download/upload bandwidth container
In reply to Marek LindnerPrior to this patch batman-adv read the advertised uplink bandwidth from userspace and compressed this information into a single byte called "gateway class".
Now the download & upload bandwidth information is sent as-is. No userspace change is necessary since the sysfs API always allowed to specify a bandwidth.
--- bat_iv_ogm.c | 23 +----- gateway_client.c | 185 +++++++++++++++++++++++++++---------------- gateway_client.h | 2 +- gateway_common.c | 232 +++++++++++++++++++++++++++++++++++------------------- gateway_common.h | 14 +++- main.c | 7 ++ originator.c | 4 +- packet.h | 21 ++++- soft-interface.c | 3 +- sysfs.c | 17 ++-- types.h | 12 ++- 11 files changed, 329 insertions(+), 191 deletions(-)
bat_iv_ogm.c +1 -22
@@ -118,6 +118,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface) batadv_ogm_packet->header.version =BATADV_COMPAT_VERSION ; batadv_ogm_packet->header.ttl =2 ; batadv_ogm_packet->flags =BATADV_NO_FLAGS ; + batadv_ogm_packet->reserved =0 ; batadv_ogm_packet->tq =BATADV_TQ_MAX_VALUE ; batadv_ogm_packet->tt_num_changes =0 ; batadv_ogm_packet->ttvn =0 ;
@@ -672,7 +673,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len;int vis_server, tt_num_changes =0 ;uint32_t seqno; -uint8_t bandwidth;uint16_t tvlv_len =0 ; vis_server =atomic_read (&bat_priv->vis_mode);
@@ -701,14 +701,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)else batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER ; -if (hard_iface == primary_if && -atomic_read (&bat_priv->gw_mode) ==BATADV_GW_MODE_SERVER ) { - bandwidth = (uint8_t )atomic_read (&bat_priv->gw_bandwidth); - batadv_ogm_packet->gw_flags = bandwidth; - }else { - batadv_ogm_packet->gw_flags =BATADV_NO_FLAGS ; - } -batadv_iv_ogm_slide_own_bcast_window (hard_iface); batadv_iv_ogm_queue_add(bat_priv, hard_iface->bat_iv.ogm_buff, hard_iface->bat_iv.ogm_buff_len, hard_iface, 1,
@@ -843,19 +835,6 @@ update_tt: batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->ttvn, ntohs(batadv_ogm_packet->tt_crc)); - -if (orig_node->gw_flags != batadv_ogm_packet->gw_flags) -batadv_gw_node_update (bat_priv, orig_node, - batadv_ogm_packet->gw_flags); - - orig_node->gw_flags = batadv_ogm_packet->gw_flags; - -/* restart gateway selection if fast or late switching was enabled */ -if ((orig_node->gw_flags) && - (atomic_read (&bat_priv->gw_mode) ==BATADV_GW_MODE_CLIENT ) && - (atomic_read (&bat_priv->gw_sel_class) >2 )) -batadv_gw_check_election (bat_priv, orig_node); - goto out; unlock:
gateway_client.c +119 -66
289 lines not on this page · raw message
gateway_client.h +1 -1
@@ -28,7 +28,7 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node);void batadv_gw_node_update (struct batadv_priv *bat_priv,struct batadv_orig_node *orig_node, -uint8_t new_gwflags); +struct batadv_tvlv_gateway_data *gateway);void batadv_gw_node_delete (struct batadv_priv *bat_priv,struct batadv_orig_node *orig_node);void batadv_gw_node_purge (struct batadv_priv *bat_priv);
gateway_common.c +149 -83
293 lines not on this page · raw message
gateway_common.h +13 -1
@@ -26,12 +26,24 @@ enum batadv_gw_modes { BATADV_GW_MODE_SERVER, }; +/** +* enum batadv_bandwidth_units - bandwidth unit types +* @BATADV_BW_UNIT_KBIT: unit type kbit +* @BATADV_BW_UNIT_MBIT: unit type mbit +*/ +enum batadv_bandwidth_types { +BATADV_BW_UNIT_KBIT , +BATADV_BW_UNIT_MBIT , +}; +#define BATADV_GW_MODE_OFF_NAME "off"#define BATADV_GW_MODE_CLIENT_NAME "client"#define BATADV_GW_MODE_SERVER_NAME "server" -void batadv_gw_bandwidth_to_kbit (uint8_t gw_class,int *down,int *up);ssize_t batadv_gw_bandwidth_set (struct net_device *net_dev,char *buff,size_t count); +void batadv_gw_tvlv_container_update (struct batadv_priv *bat_priv); +int batadv_gw_init (struct batadv_priv *bat_priv); +void batadv_gw_free (struct batadv_priv *bat_priv);#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */
main.c +7 -0
@@ -33,6 +33,7 @@#include "bridge_loop_avoidance.h" #include "distributed-arp-table.h" #include "unicast.h" +#include "gateway_common.h" #include "vis.h" #include "hash.h" #include "bat_algo.h"
@@ -147,6 +148,10 @@ int batadv_mesh_init(struct net_device *soft_iface)if (ret <0 ) goto err; + ret =batadv_gw_init (bat_priv); +if (ret <0 ) + goto err; +atomic_set (&bat_priv->gw.reselect,0 );atomic_set (&bat_priv->mesh_state,BATADV_MESH_ACTIVE );
@@ -177,6 +182,8 @@ void batadv_mesh_free(struct net_device *soft_iface)batadv_dat_free (bat_priv); +batadv_gw_free (bat_priv); +free_percpu (bat_priv->bat_counters); bat_priv->bat_counters =NULL ;
originator.c +1 -3
@@ -388,9 +388,7 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv)hlist_for_each_entry_safe (orig_node, node_tmp, head, hash_entry) {if (batadv_purge_orig_node (bat_priv, orig_node)) { -if (orig_node->gw_flags) -batadv_gw_node_delete (bat_priv, - orig_node); +batadv_gw_node_delete (bat_priv, orig_node);hlist_del_rcu (&orig_node->hash_entry);batadv_orig_node_free_ref (orig_node);continue ;
packet.h +20 -1
@@ -118,6 +118,14 @@ enum batadv_bla_claimframe { BATADV_CLAIM_TYPE_REQUEST = 0x03, }; +/** +* enum batadv_tvlv_type - tvlv type definitions +* @BATADV_TVLV_GW: gateway tvlv +*/ +enum batadv_tvlv_type { +BATADV_TVLV_GW =0x01 , +}; +/* the destination hardware field in the ARP frame is used to * transport the claim type and the group id */
@@ -147,7 +155,7 @@ struct batadv_ogm_packet {__be32 seqno;uint8_t orig[ETH_ALEN ];uint8_t prev_sender[ETH_ALEN ]; -uint8_t gw_flags;/* flags related to gateway class */ +uint8_t reserved;uint8_t tq;uint8_t tt_num_changes;uint8_t ttvn;/* translation table version number */
@@ -378,4 +386,15 @@ struct batadv_tvlv_long { __be16 len; }; +/** +* struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv +* container +* @bandwidth_down: advertised uplink download bandwidth +* @bandwidth_up: advertised uplink upload bandwidth +*/ +struct batadv_tvlv_gateway_data { +uint32_t bandwidth_down; +uint32_t bandwidth_up; +}; +#endif /* _NET_BATMAN_ADV_PACKET_H_ */
soft-interface.c +2 -1
@@ -461,7 +461,8 @@ static int batadv_softif_init_late(struct net_device *dev)atomic_set (&bat_priv->vis_mode,BATADV_VIS_TYPE_CLIENT_UPDATE );atomic_set (&bat_priv->gw_mode,BATADV_GW_MODE_OFF );atomic_set (&bat_priv->gw_sel_class,20 ); -atomic_set (&bat_priv->gw_bandwidth,41 ); +atomic_set (&bat_priv->gw.bandwidth_down,100 ); +atomic_set (&bat_priv->gw.bandwidth_up,20 );atomic_set (&bat_priv->orig_interval,1000 );atomic_set (&bat_priv->hop_penalty,30 );#ifdef CONFIG_BATMAN_ADV_DEBUG
sysfs.c +8 -9
@@ -386,6 +386,7 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,batadv_gw_deselect (bat_priv);atomic_set (&bat_priv->gw_mode, (unsigned int )gw_mode_tmp); +batadv_gw_tvlv_container_update (bat_priv);return count; }
@@ -393,15 +394,13 @@ static ssize_t batadv_show_gw_bwidth(struct kobject *kobj, struct attribute *attr, char *buff) { struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); -int down, up; -int gw_bandwidth =atomic_read (&bat_priv->gw_bandwidth); - -batadv_gw_bandwidth_to_kbit (gw_bandwidth, &down, &up); -return sprintf (buff,"%i%s/%i%s\n" , - (down >2048 ? down /1024 : down), - (down >2048 ?"MBit" :"KBit" ), - (up >2048 ? up /1024 : up), - (up >2048 ?"MBit" :"KBit" )); +uint32_t down, up; + + down =atomic_read (&bat_priv->gw.bandwidth_down); + up =atomic_read (&bat_priv->gw.bandwidth_up); + +return sprintf (buff,"%u.%u/%u.%u MBit\n" , down /10 , + down %10 , up /10 , up %10 ); } static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
types.h +8 -4
@@ -99,7 +99,6 @@ struct batadv_hard_iface {* @last_seen: time when last packet from this node was received * @bcast_seqno_reset: time when the broadcast seqno window was reset * @batman_seqno_reset: time when the batman seqno window was reset -* @gw_flags: flags related to gateway class * @flags: for now only VIS_SERVER flag * @last_ttvn: last seen translation table version number * @tt_crc: CRC of the translation table
@@ -147,7 +146,6 @@ struct batadv_orig_node {unsigned long last_seen;unsigned long bcast_seqno_reset;unsigned long batman_seqno_reset; -uint8_t gw_flags;uint8_t flags;atomic_t last_ttvn;uint16_t tt_crc;
@@ -189,6 +187,8 @@ struct batadv_orig_node {* struct batadv_gw_node - structure for orig nodes announcing gw capabilities * @list: list node for batadv_priv_gw::list * @orig_node: pointer to corresponding orig node +* @bandwidth_down: advertised uplink download bandwidth +* @bandwidth_up: advertised uplink upload bandwidth * @deleted: this struct is scheduled for deletion * @refcount: number of contexts the object is used * @rcu: struct used for freeing in an RCU-safe manner
@@ -196,6 +196,8 @@ struct batadv_orig_node {struct batadv_gw_node {struct hlist_node list;struct batadv_orig_node *orig_node; +uint32_t bandwidth_down; +uint32_t bandwidth_up;unsigned long deleted;atomic_t refcount;struct rcu_head rcu;
@@ -420,12 +422,16 @@ struct batadv_priv_debug_log {* @list: list of available gateway nodes * @list_lock: lock protecting gw_list & curr_gw * @curr_gw: pointer to currently selected gateway node +* @bandwidth_down: advertised uplink download bandwidth (if gw_mode server) +* @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server) * @reselect: bool indicating a gateway re-selection is in progress */ struct batadv_priv_gw {struct hlist_head list;spinlock_t list_lock;/* protects gw_list & curr_gw */ struct batadv_gw_node __rcu *curr_gw;/* rcu protected pointer */ +atomic_t bandwidth_down; +atomic_t bandwidth_up;atomic_t reselect; };
@@ -521,7 +527,6 @@ struct batadv_priv_nc {* @vis_mode: vis operation: client or server (see batadv_vis_packettype) * @gw_mode: gateway operation: off, client or server (see batadv_gw_modes) * @gw_sel_class: gateway selection class (applies if gw_mode client) -* @gw_bandwidth: gateway announced bandwidth (applies if gw_mode server) * @orig_interval: OGM broadcast interval in milliseconds * @hop_penalty: penalty which will be applied to an OGM's tq-field on every hop * @log_level: configured log level (see batadv_dbg_level)
@@ -569,7 +574,6 @@ struct batadv_priv {atomic_t vis_mode;atomic_t gw_mode;atomic_t gw_sel_class; -atomic_t gw_bandwidth;atomic_t orig_interval;atomic_t hop_penalty;#ifdef CONFIG_BATMAN_ADV_DEBUG
Signature · 1 line
1.7.10.4
PATCH v2 3/7 batman-adv: tvlv - add distributed arp table container
In reply to Marek LindnerCreate DAT container to announce DAT capabilities (if enabled).
--- distributed-arp-table.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ distributed-arp-table.h | 5 ++++ packet.h | 2 ++ sysfs.c | 3 ++- types.h | 10 ++++++++ 5 files changed, 83 insertions(+), 1 deletion(-)
distributed-arp-table.c +64 -0
@@ -419,6 +419,10 @@ static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res,bool ret = false;int j; +/* check if orig node candidate is running DAT */ +if (!(candidate->capabilities &BATADV_ORIG_CAPA_HAS_DAT )) + goto out; +/* Check if this node has already been selected... */ for (j =0 ; j < select; j++)if (res[j].orig_node == candidate)
@@ -626,6 +630,59 @@ out: }/** +* batadv_dat_tvlv_container_update - update the dat tvlv container after dat +* setting change +* @bat_priv: the bat priv with all the soft interface information +*/ +static void batadv_dat_tvlv_container_update (struct batadv_priv *bat_priv) +{ +char dat_mode; + + dat_mode =atomic_read (&bat_priv->distributed_arp_table); + +switch (dat_mode) { +case 0 : +batadv_tvlv_container_unregister (bat_priv,BATADV_TVLV_DAT ,1 ); +break ; +case 1 : +batadv_tvlv_container_register (bat_priv,BATADV_TVLV_DAT ,1 , +NULL ,0 ); +break ; + } +} + +/** +* batadv_dat_status_update - update the dat tvlv container after dat +* setting change +* @net_dev: the soft interface net device +*/ +void batadv_dat_status_update (struct net_device *net_dev) +{ +struct batadv_priv *bat_priv =netdev_priv (net_dev); +batadv_dat_tvlv_container_update (bat_priv); +} + +/** +* batadv_gw_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) +* @tvlv_value: tvlv buffer containing the gateway data +* @tvlv_value_len: tvlv buffer length +*/ +static void batadv_dat_tvlv_ogm_handler_v1 (struct batadv_priv *bat_priv, +struct batadv_orig_node *orig, +uint8_t flags, +void *tvlv_value, +uint16_t tvlv_value_len) +{ +if (flags &BATADV_TVLV_HANDLER_OGM_CIFNOTFND ) + orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_DAT ; +else + orig->capabilities |=BATADV_ORIG_CAPA_HAS_DAT ; +} + +/** * batadv_dat_hash_free - free the local DAT hash table * @bat_priv: the bat priv with all the soft interface information */
@@ -657,6 +714,10 @@ int batadv_dat_init(struct batadv_priv *bat_priv)batadv_dat_start_timer (bat_priv); +batadv_tvlv_handler_register (bat_priv, batadv_dat_tvlv_ogm_handler_v1, +NULL ,BATADV_TVLV_DAT ,1 , +BATADV_TVLV_HANDLER_OGM_CIFNOTFND ); +batadv_dat_tvlv_container_update (bat_priv);return 0 ; }
@@ -666,6 +727,9 @@ int batadv_dat_init(struct batadv_priv *bat_priv)*/ void batadv_dat_free (struct batadv_priv *bat_priv) { +batadv_tvlv_container_unregister (bat_priv,BATADV_TVLV_DAT ,1 ); +batadv_tvlv_handler_unregister (bat_priv,BATADV_TVLV_DAT ,1 ); +cancel_delayed_work_sync (&bat_priv->dat.work);batadv_dat_hash_free (bat_priv);
distributed-arp-table.h +5 -0
@@ -29,6 +29,7 @@#define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0) +void batadv_dat_status_update (struct net_device *net_dev);bool batadv_dat_snoop_outgoing_arp_request (struct batadv_priv *bat_priv,struct sk_buff *skb); bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
@@ -98,6 +99,10 @@ static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,#else +static inline void batadv_dat_status_update (struct net_device *net_dev) +{ +} +static inline bool batadv_dat_snoop_outgoing_arp_request (struct batadv_priv *bat_priv,struct sk_buff *skb)
packet.h +2 -0
@@ -121,9 +121,11 @@ enum batadv_bla_claimframe {/** * enum batadv_tvlv_type - tvlv type definitions * @BATADV_TVLV_GW: gateway tvlv +* @BATADV_TVLV_DAT: distributed arp table tvlv */ enum batadv_tvlv_type {BATADV_TVLV_GW =0x01 , +BATADV_TVLV_DAT =0x02 , };/* the destination hardware field in the ARP frame is used to
sysfs.c +2 -1
@@ -421,7 +421,8 @@ BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);BATADV_ATTR_SIF_BOOL (bridge_loop_avoidance,S_IRUGO |S_IWUSR ,NULL );#endif #ifdef CONFIG_BATMAN_ADV_DAT -BATADV_ATTR_SIF_BOOL (distributed_arp_table,S_IRUGO |S_IWUSR ,NULL ); +BATADV_ATTR_SIF_BOOL (distributed_arp_table,S_IRUGO |S_IWUSR , + batadv_dat_status_update);#endif BATADV_ATTR_SIF_BOOL (fragmentation,S_IRUGO |S_IWUSR , batadv_update_min_mtu);BATADV_ATTR_SIF_BOOL (ap_isolation,S_IRUGO |S_IWUSR ,NULL );
types.h +10 -0
@@ -100,6 +100,7 @@ struct batadv_hard_iface {* @bcast_seqno_reset: time when the broadcast seqno window was reset * @batman_seqno_reset: time when the batman seqno window was reset * @flags: for now only VIS_SERVER flag +* @capabilities: announced capabilities of this originator * @last_ttvn: last seen translation table version number * @tt_crc: CRC of the translation table * @tt_buff: last tt changeset this node received from the orig node
@@ -147,6 +148,7 @@ struct batadv_orig_node {unsigned long bcast_seqno_reset;unsigned long batman_seqno_reset;uint8_t flags; +uint8_t capabilities;atomic_t last_ttvn;uint16_t tt_crc;unsigned char *tt_buff;
@@ -184,6 +186,14 @@ struct batadv_orig_node { };/** +* enum batadv_orig_capabilities - orig node capabilities +* @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled +*/ +enum batadv_orig_capabilities { +BATADV_ORIG_CAPA_HAS_DAT =BIT (1 ), +}; + +/** * struct batadv_gw_node - structure for orig nodes announcing gw capabilities * @list: list node for batadv_priv_gw::list * @orig_node: pointer to corresponding orig node
Signature · 1 line
1.7.10.4
PATCH v2 4/7 batman-adv: tvlv - add network coding container
In reply to Marek LindnerCreate network coding container to announce network coding capabilities (if enabled).
--- network-coding.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ network-coding.h | 6 ++++++ packet.h | 2 ++ sysfs.c | 4 +++- types.h | 2 ++ 5 files changed, 76 insertions(+), 1 deletion(-)
network-coding.c +63 -0
@@ -45,6 +45,59 @@ static void batadv_nc_start_timer(struct batadv_priv *bat_priv) }/** +* batadv_nc_tvlv_container_update - update the network coding tvlv container +* after network coding setting change +* @bat_priv: the bat priv with all the soft interface information +*/ +static void batadv_nc_tvlv_container_update (struct batadv_priv *bat_priv) +{ +char nc_mode; + + nc_mode =atomic_read (&bat_priv->network_coding); + +switch (nc_mode) { +case 0 : +batadv_tvlv_container_unregister (bat_priv,BATADV_TVLV_NC ,1 ); +break ; +case 1 : +batadv_tvlv_container_register (bat_priv,BATADV_TVLV_NC ,1 , +NULL ,0 ); +break ; + } +} + +/** +* batadv_nc_status_update - update the network coding tvlv container after +* network coding setting change +* @net_dev: the soft interface net device +*/ +void batadv_nc_status_update (struct net_device *net_dev) +{ +struct batadv_priv *bat_priv =netdev_priv (net_dev); +batadv_nc_tvlv_container_update (bat_priv); +} + +/** +* batadv_nc_tvlv_ogm_handler_v1 - process incoming nc 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) +* @tvlv_value: tvlv buffer containing the gateway data +* @tvlv_value_len: tvlv buffer length +*/ +static void batadv_nc_tvlv_ogm_handler_v1 (struct batadv_priv *bat_priv, +struct batadv_orig_node *orig, +uint8_t flags, +void *tvlv_value, +uint16_t tvlv_value_len) +{ +if (flags &BATADV_TVLV_HANDLER_OGM_CIFNOTFND ) + orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_NC ; +else + orig->capabilities |=BATADV_ORIG_CAPA_HAS_NC ; +} + +/** * batadv_nc_init - initialise coding hash table and start house keeping * @bat_priv: the bat priv with all the soft interface information */
@@ -78,6 +131,10 @@ int batadv_nc_init(struct batadv_priv *bat_priv)INIT_DELAYED_WORK (&bat_priv->nc.work, batadv_nc_worker);batadv_nc_start_timer (bat_priv); +batadv_tvlv_handler_register (bat_priv, batadv_nc_tvlv_ogm_handler_v1, +NULL ,BATADV_TVLV_NC ,1 , +BATADV_TVLV_HANDLER_OGM_CIFNOTFND ); +batadv_nc_tvlv_container_update (bat_priv);return 0 ; err:
@@ -793,6 +850,10 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,if (!atomic_read (&bat_priv->network_coding)) goto out; +/* check if orig node is network coding enabled */ +if (!(orig_node->capabilities &BATADV_ORIG_CAPA_HAS_NC )) + goto out; +/* accept ogms from 'good' neighbors and single hop neighbors */ if (!batadv_can_nc_with_orig (bat_priv, orig_node, ogm_packet) && !is_single_hop_neigh)
@@ -1723,6 +1784,8 @@ free_nc_packet:void batadv_nc_free (struct batadv_priv *bat_priv) {batadv_recv_handler_unregister (BATADV_CODED ); +batadv_tvlv_container_unregister (bat_priv,BATADV_TVLV_NC ,1 ); +batadv_tvlv_handler_unregister (bat_priv,BATADV_TVLV_NC ,1 );cancel_delayed_work_sync (&bat_priv->nc.work);batadv_nc_purge_paths (bat_priv, bat_priv->nc.coding_hash,NULL );
network-coding.h +6 -0
@@ -22,6 +22,7 @@#ifdef CONFIG_BATMAN_ADV_NC +void batadv_nc_status_update (struct net_device *net_dev);int batadv_nc_init (struct batadv_priv *bat_priv);void batadv_nc_free (struct batadv_priv *bat_priv); void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
@@ -46,6 +47,11 @@ int batadv_nc_init_debugfs(struct batadv_priv *bat_priv);#else /* ifdef CONFIG_BATMAN_ADV_NC */ +static inline void batadv_nc_status_update (struct net_device *net_dev) +{ +return ; +} +static inline int batadv_nc_init (struct batadv_priv *bat_priv) {return 0 ;
packet.h +2 -0
@@ -122,10 +122,12 @@ enum batadv_bla_claimframe {* enum batadv_tvlv_type - tvlv type definitions * @BATADV_TVLV_GW: gateway tvlv * @BATADV_TVLV_DAT: distributed arp table tvlv +* @BATADV_TVLV_NC: network coding tvlv */ enum batadv_tvlv_type {BATADV_TVLV_GW =0x01 ,BATADV_TVLV_DAT =0x02 , +BATADV_TVLV_NC =0x03 , };/* the destination hardware field in the ARP frame is used to
sysfs.c +3 -1
@@ -21,6 +21,7 @@#include "sysfs.h" #include "translation-table.h" #include "distributed-arp-table.h" +#include "network-coding.h" #include "originator.h" #include "hard-interface.h" #include "gateway_common.h"
@@ -443,7 +444,8 @@ static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,BATADV_ATTR_SIF_UINT (log_level,S_IRUGO |S_IWUSR ,0 ,BATADV_DBG_ALL ,NULL );#endif #ifdef CONFIG_BATMAN_ADV_NC -BATADV_ATTR_SIF_BOOL (network_coding,S_IRUGO |S_IWUSR ,NULL ); +BATADV_ATTR_SIF_BOOL (network_coding,S_IRUGO |S_IWUSR , + batadv_nc_status_update);#endif static struct batadv_attribute *batadv_mesh_attrs[] = {
types.h +2 -0
@@ -188,9 +188,11 @@ struct batadv_orig_node {/** * enum batadv_orig_capabilities - orig node capabilities * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled +* @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled */ enum batadv_orig_capabilities {BATADV_ORIG_CAPA_HAS_DAT =BIT (1 ), +BATADV_ORIG_CAPA_HAS_NC =BIT (2 ), };/**
Signature · 1 line
1.7.10.4
PATCH v2 5/7 batman-adv: tvlv - convert tt data sent within OGMs
In reply to Marek LindnerThe translation table meta data (version number, crc checksum, etc) as well as the translation table diff propgated within OGMs now uses the newly introduced tvlv infrastructure.
--- bat_iv_ogm.c | 44 +++------- packet.h | 51 ++++++++--- translation-table.c | 238 ++++++++++++++++++++++++++++----------------------- translation-table.h | 8 +- types.h | 2 +- 5 files changed, 186 insertions(+), 157 deletions(-)
bat_iv_ogm.c +14 -30
@@ -120,8 +120,6 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface) batadv_ogm_packet->flags =BATADV_NO_FLAGS ; batadv_ogm_packet->reserved =0 ; batadv_ogm_packet->tq =BATADV_TQ_MAX_VALUE ; - batadv_ogm_packet->tt_num_changes =0 ; - batadv_ogm_packet->ttvn =0 ; res =0 ;
@@ -240,14 +238,14 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet, fwd_str ="Sending own" ;batadv_dbg (BATADV_DBG_BATMAN , bat_priv, -"%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n" , +"%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s) on interface %s [%pM]\n" , fwd_str, (packet_num >0 ?"aggregated " :"" ), batadv_ogm_packet->orig,ntohl (batadv_ogm_packet->seqno), batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl, (batadv_ogm_packet->flags &BATADV_DIRECTLINK ?"on" :"off" ), - batadv_ogm_packet->ttvn, hard_iface->net_dev->name, + hard_iface->net_dev->name, hard_iface->net_dev->dev_addr); buff_pos +=BATADV_OGM_HLEN ;
@@ -671,17 +669,22 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)struct batadv_ogm_packet *batadv_ogm_packet;struct batadv_hard_iface *primary_if;int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len; -int vis_server, tt_num_changes =0 ; +int vis_server;uint32_t seqno;uint16_t tvlv_len =0 ; vis_server =atomic_read (&bat_priv->vis_mode); primary_if =batadv_primary_if_get_selected (bat_priv); -if (hard_iface == primary_if) +if (hard_iface == primary_if) { +/* tt changes have to be committed before the tvlv data is +* appended as it may alter the tt tvlv container +*/ +batadv_tt_local_commit_changes (bat_priv); tvlv_len =batadv_tvlv_container_ogm_append (bat_priv, ogm_buff, ogm_buff_len,BATADV_OGM_HLEN ); + } batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff); batadv_ogm_packet->tvlv_len =htons (tvlv_len);
@@ -691,11 +694,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) batadv_ogm_packet->seqno =htonl (seqno);atomic_inc (&hard_iface->bat_iv.ogm_seqno); - batadv_ogm_packet->ttvn =atomic_read (&bat_priv->tt.vn); - batadv_ogm_packet->tt_crc =htons (bat_priv->tt.local_crc); -if (tt_num_changes >=0 ) - batadv_ogm_packet->tt_num_changes = tt_num_changes; -if (vis_server ==BATADV_VIS_TYPE_SERVER_SYNC ) batadv_ogm_packet->flags |=BATADV_VIS_SERVER ;else
@@ -796,11 +794,11 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,*/ router =batadv_orig_node_get_router (orig_node);if (router == neigh_node) - goto update_tt; + goto out;/* if this neighbor does not offer a better TQ we won't consider it */ if (router && (router->tq_avg > neigh_node->tq_avg)) - goto update_tt; + goto out;/* if the TQ is the same and the link not more symmetric we * won't consider it either
@@ -819,22 +817,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,spin_unlock_bh (&orig_node_tmp->ogm_cnt_lock);if (sum_orig >= sum_neigh) - goto update_tt; + goto out; }batadv_update_route (bat_priv, orig_node, neigh_node); - -update_tt: -/* I have to check for transtable changes only if the OGM has been -* sent through a primary interface -*/ -if (((batadv_ogm_packet->orig != ethhdr->h_source) && - (batadv_ogm_packet->header.ttl >2 )) || - (batadv_ogm_packet->flags &BATADV_PRIMARIES_FIRST_HOP )) -batadv_tt_update_orig (bat_priv, orig_node, tt_buff, - batadv_ogm_packet->tt_num_changes, - batadv_ogm_packet->ttvn, -ntohs (batadv_ogm_packet->tt_crc)); goto out; unlock:
@@ -1077,13 +1063,11 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, is_single_hop_neigh = true;batadv_dbg (BATADV_DBG_BATMAN , bat_priv, -"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %#.4x, changes %u, tq %d, TTL %d, V %d, IDF %d)\n" , +"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, tq %d, TTL %d, V %d, IDF %d)\n" , ethhdr->h_source, if_incoming->net_dev->name, if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig, batadv_ogm_packet->prev_sender, -ntohl (batadv_ogm_packet->seqno), batadv_ogm_packet->ttvn, -ntohs (batadv_ogm_packet->tt_crc), - batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->tq, +ntohl (batadv_ogm_packet->seqno), batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl, batadv_ogm_packet->header.version, has_directlink_flag);
packet.h +41 -10
79 lines not on this page · raw message
translation-table.c +129 -109
321 lines not on this page · raw message
translation-table.h +1 -7
@@ -50,13 +50,7 @@ void batadv_handle_tt_response(struct batadv_priv *bat_priv, struct batadv_tt_query_packet *tt_response);bool batadv_is_ap_isolated (struct batadv_priv *bat_priv,uint8_t *src,uint8_t *dst); -void batadv_tt_update_orig (struct batadv_priv *bat_priv, -struct batadv_orig_node *orig_node, -const unsigned char *tt_buff,uint8_t tt_num_changes, -uint8_t ttvn,uint16_t tt_crc); -int batadv_tt_append_diff (struct batadv_priv *bat_priv, -unsigned char **packet_buff,int *packet_buff_len, -int packet_min_len); +void batadv_tt_local_commit_changes (struct batadv_priv *bat_priv);bool batadv_tt_global_client_is_roaming (struct batadv_priv *bat_priv,uint8_t *addr); bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
types.h +1 -1
@@ -772,7 +772,7 @@ struct batadv_tt_orig_list_entry {*/ struct batadv_tt_change_node {struct list_head list; -struct batadv_tt_change change; +struct batadv_tvlv_tt_change change; };/**
Signature · 1 line
1.7.10.4
PATCH v2 6/7 batman-adv: tvlv - convert tt query packet to use tvlv unicast packets
In reply to Marek LindnerInstead of generating TT specific packets the TVLV unicast API is used to send translation table data.
--- main.c | 2 - packet.h | 33 ---- routing.c | 78 -------- translation-table.c | 498 +++++++++++++++++++++++++++++---------------------- translation-table.h | 5 - 5 files changed, 286 insertions(+), 330 deletions(-)
main.c +0 -2
@@ -349,8 +349,6 @@ static void batadv_recv_handler_init(void) batadv_rx_handler[BATADV_BCAST ] = batadv_recv_bcast_packet;/* vis packet */ batadv_rx_handler[BATADV_VIS ] = batadv_recv_vis_packet; -/* Translation table query (request or response) */ - batadv_rx_handler[BATADV_TT_QUERY ] = batadv_recv_tt_query;/* Roaming advertisement */ batadv_rx_handler[BATADV_ROAM_ADV ] = batadv_recv_roam_adv;/* unicast tvlv packet */
packet.h +0 -33
@@ -31,7 +31,6 @@ enum batadv_packettype {BATADV_BCAST =0x04 ,BATADV_VIS =0x05 ,BATADV_UNICAST_FRAG =0x06 , -BATADV_TT_QUERY =0x07 ,BATADV_ROAM_ADV =0x08 ,BATADV_UNICAST_4ADDR =0x09 , BATADV_CODED = 0x0a,
@@ -83,9 +82,6 @@ enum batadv_unicast_frag_flags { BATADV_UNI_FRAG_LARGETAIL = BIT(1), }; -/* TT_QUERY subtypes */ -#define BATADV_TT_QUERY_TYPE_MASK 0x3 -/* tt data subtypes */ #define BATADV_TT_DATA_TYPE_MASK 0x0F
@@ -271,30 +267,6 @@ struct batadv_vis_packet {uint8_t sender_orig[ETH_ALEN ];/* who sent or forwarded this packet */ }; -struct batadv_tt_query_packet { -struct batadv_header header; -/* the flag field is a combination of: -* - TT_REQUEST or TT_RESPONSE -* - TT_FULL_TABLE -*/ -uint8_t flags; -uint8_t dst[ETH_ALEN ]; -uint8_t src[ETH_ALEN ]; -/* the ttvn field is: -* if TT_REQUEST: ttvn that triggered the -* request -* if TT_RESPONSE: new ttvn for the src -* orig_node -*/ -uint8_t ttvn; -/* tt_data field is: -* if TT_REQUEST: crc associated with the -* ttvn -* if TT_RESPONSE: table_size -*/ -__be16 tt_data; -} __packed; -struct batadv_roam_adv_packet {struct batadv_header header;uint8_t reserved;
@@ -303,11 +275,6 @@ struct batadv_roam_adv_packet {uint8_t client[ETH_ALEN ]; } __packed; -struct batadv_tt_change { -uint8_t flags; -uint8_t addr[ETH_ALEN ]; -} __packed; -/** * struct batadv_coded_packet - network coded packet * @header: common batman packet header and ttl of first included packet
routing.c +0 -78
84 lines not on this page · raw message
translation-table.c +286 -212
775 lines not on this page · raw message
translation-table.h +0 -5
@@ -20,7 +20,6 @@#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ -int batadv_tt_len (int changes_num);int batadv_tt_init (struct batadv_priv *bat_priv);void batadv_tt_local_add (struct net_device *soft_iface,const uint8_t *addr,int ifindex);
@@ -43,11 +42,7 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,const uint8_t *src, const uint8_t *addr);void batadv_tt_free (struct batadv_priv *bat_priv); -bool batadv_send_tt_response (struct batadv_priv *bat_priv, -struct batadv_tt_query_packet *tt_request);bool batadv_is_my_client (struct batadv_priv *bat_priv,const uint8_t *addr); -void batadv_handle_tt_response (struct batadv_priv *bat_priv, -struct batadv_tt_query_packet *tt_response);bool batadv_is_ap_isolated (struct batadv_priv *bat_priv,uint8_t *src,uint8_t *dst);void batadv_tt_local_commit_changes (struct batadv_priv *bat_priv);
Signature · 1 line
1.7.10.4
PATCH v2 7/7 batman-adv: tvlv - convert roaming adv packet to use tvlv unicast packets
In reply to Marek LindnerInstead of generating roaming specific packets the TVLV unicast API is used to send roaming information.
--- main.c | 2 - packet.h | 19 +++++----- routing.c | 42 --------------------- translation-table.c | 102 ++++++++++++++++++++++++++++++++++++--------------- 4 files changed, 83 insertions(+), 82 deletions(-)
main.c +0 -2
@@ -349,8 +349,6 @@ static void batadv_recv_handler_init(void) batadv_rx_handler[BATADV_BCAST ] = batadv_recv_bcast_packet;/* vis packet */ batadv_rx_handler[BATADV_VIS ] = batadv_recv_vis_packet; -/* Roaming advertisement */ - batadv_rx_handler[BATADV_ROAM_ADV ] = batadv_recv_roam_adv;/* unicast tvlv packet */ batadv_rx_handler[BATADV_UNICAST_TVLV ] = batadv_recv_unicast_tvlv; }
packet.h +10 -9
@@ -31,7 +31,6 @@ enum batadv_packettype {BATADV_BCAST =0x04 ,BATADV_VIS =0x05 ,BATADV_UNICAST_FRAG =0x06 , -BATADV_ROAM_ADV =0x08 ,BATADV_UNICAST_4ADDR =0x09 ,BATADV_CODED =0x0a , BATADV_UNICAST_TVLV = 0x0b,
@@ -127,12 +126,14 @@ enum batadv_bla_claimframe {* @BATADV_TVLV_DAT: distributed arp table tvlv * @BATADV_TVLV_NC: network coding tvlv * @BATADV_TVLV_TT: translation table tvlv +* @BATADV_TVLV_ROAM: roaming advertisement tvlv */ enum batadv_tvlv_type {BATADV_TVLV_GW =0x01 ,BATADV_TVLV_DAT =0x02 ,BATADV_TVLV_NC =0x03 ,BATADV_TVLV_TT =0x04 , +BATADV_TVLV_ROAM =0x05 , };/* the destination hardware field in the ARP frame is used to
@@ -267,14 +268,6 @@ struct batadv_vis_packet {uint8_t sender_orig[ETH_ALEN ];/* who sent or forwarded this packet */ }; -struct batadv_roam_adv_packet { -struct batadv_header header; -uint8_t reserved; -uint8_t dst[ETH_ALEN ]; -uint8_t src[ETH_ALEN ]; -uint8_t client[ETH_ALEN ]; -} __packed; -/** * struct batadv_coded_packet - network coded packet * @header: common batman packet header and ttl of first included packet
@@ -399,4 +392,12 @@ struct batadv_tvlv_tt_change { uint8_t addr[ETH_ALEN]; }; +/** +* struct batadv_tvlv_roam_adv - roaming advertisement +* @client: mac address of roaming client +*/ +struct batadv_tvlv_roam_adv { +uint8_t client[ETH_ALEN ]; +}; +#endif /* _NET_BATMAN_ADV_PACKET_H_ */
routing.c +0 -42
48 lines not on this page · raw message
translation-table.c +73 -29
135 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 1/7] batman-adv: tvlv - basic infrastructure
In reply to Marek LindnerQuoted 19 lines · On Tuesday, April 23, 2013 21:39:57 Marek Lindner wrote:
The goal is to provide the infrastructure for sending, receiving and parsing information 'containers' while preserving backward compatibility. TVLV (based on the commonly known Type Length Value technique) was chosen as the format for those containers. Even if a node does not know the tvlv type of a certain container it can simply skip the current container and proceed with the next. Past experience has shown features evolve over time, so a 'version' field was added right from the start to allow differentiating between feature variants - hence the name: T(ype) V(ersion) L(ength) V(alue).
This patch introduces the basic TVLV infrastructure:
* register / unregister tvlv containers to be sent with each OGM (on primary interfaces only)
* register / unregister callback handlers to be called upon finding the corresponding tvlv type in a tvlv buffer
* unicast tvlv send / receive API callsSigned-off-by Marek Lindner <[email protected]>Signed-off-by Spyros Gasteratos <[email protected]>
Quoted 12 lines
--- bat_iv_ogm.c | 38 ++-- compat.c | 8 + compat.h | 1 + main.c | 620 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.h | 35 ++++ packet.h | 67 +++++++ routing.c | 48 +++++ routing.h | 2 + types.h | 73 +++++++ 9 files changed, 875 insertions(+), 17 deletions(-)
Applied in revision 0b6aa0d.
Thanks,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 2/7] batman-adv: tvlv - gateway download/upload bandwidth container
In reply to Marek LindnerQuoted 9 lines · On Tuesday, April 23, 2013 21:39:58 Marek Lindner wrote:
Prior to this patch batman-adv read the advertised uplink bandwidth from userspace and compressed this information into a single byte called "gateway class".
Now the download & upload bandwidth information is sent as-is. No userspace change is necessary since the sysfs API always allowed to specify a bandwidth.Signed-off-by Marek Lindner <[email protected]>Signed-off-by Spyros Gasteratos <[email protected]>
Quoted 14 lines
--- bat_iv_ogm.c | 23 +----- gateway_client.c | 185 +++++++++++++++++++++++++++---------------- gateway_client.h | 2 +- gateway_common.c | 232 +++++++++++++++++++++++++++++++++++------------------- gateway_common.h | 14 +++- main.c | 7 ++ originator.c | 4 +- packet.h | 21 ++++- soft-interface.c | 3 +- sysfs.c | 17 ++-- types.h | 12 ++- 11 files changed, 329 insertions(+), 191 deletions(-)
Applied in revision 0853ec7.
Regards,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 3/7] batman-adv: tvlv - add distributed arp table container
In reply to Marek LindnerQuoted 11 lines · On Tuesday, April 23, 2013 21:39:59 Marek Lindner wrote:
Create DAT container to announce DAT capabilities (if enabled).
Signed-off-by Marek Lindner <[email protected]>--- distributed-arp-table.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ distributed-arp-table.h | 5 ++++ packet.h | 2 ++ sysfs.c | 3 ++- types.h | 10 ++++++++ 5 files changed, 83 insertions(+), 1 deletion(-)
Applied in revision 2b1c07b.
Regards,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 4/7] batman-adv: tvlv - add network coding container
In reply to Marek LindnerQuoted 4 lines · On Tuesday, April 23, 2013 21:40:00 Marek Lindner wrote:
Create network coding container to announce network coding capabilities (if enabled).
Signed-off-by Marek Lindner <[email protected]>
Quoted 8 lines
--- network-coding.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ network-coding.h | 6 ++++++ packet.h | 2 ++ sysfs.c | 4 +++- types.h | 2 ++ 5 files changed, 76 insertions(+), 1 deletion(-)
Applied in revision 7dd9d89.
Regards,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 5/7] batman-adv: tvlv - convert tt data sent within OGMs
In reply to Marek LindnerQuoted 5 lines · On Tuesday, April 23, 2013 21:40:01 Marek Lindner wrote:
The translation table meta data (version number, crc checksum, etc) as well as the translation table diff propgated within OGMs now uses the newly introduced tvlv infrastructure.
Signed-off-by Marek Lindner <[email protected]>
Quoted 8 lines
--- bat_iv_ogm.c | 44 +++------- packet.h | 51 ++++++++--- translation-table.c | 238 ++++++++++++++++++++++++++++----------------------- translation-table.h | 8 +- types.h | 2 +- 5 files changed, 186 insertions(+), 157 deletions(-)
Applied in revision 8405301.
Regards,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 6/7] batman-adv: tvlv - convert tt query packet to use tvlv unicast packets
In reply to Marek LindnerQuoted 4 lines · On Tuesday, April 23, 2013 21:40:02 Marek Lindner wrote:
Instead of generating TT specific packets the TVLV unicast API is used to send translation table data.
Signed-off-by Marek Lindner <[email protected]>
Quoted 8 lines
--- main.c | 2 - packet.h | 33 ---- routing.c | 78 -------- translation-table.c | 498 +++++++++++++++++++++++++++++---------------------- translation-table.h | 5 - 5 files changed, 286 insertions(+), 330 deletions(-)
Applied in revision 6228419.
Regards,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2 7/7] batman-adv: tvlv - convert roaming adv packet to use tvlv unicast packets
In reply to Marek LindnerQuoted 11 lines · On Tuesday, April 23, 2013 21:40:03 Marek Lindner wrote:
Instead of generating roaming specific packets the TVLV unicast API is used to send roaming information.
Signed-off-by Marek Lindner <[email protected]>--- main.c | 2 - packet.h | 19 +++++----- routing.c | 42 --------------------- translation-table.c | 102++++++++++++++++++++++++++++++++++++--------------- 4 files changed, 83 insertions(+), 82 deletions(-)
Applied in revision 3de4e64.
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCHv2 1/7] batman-adv: tvlv - basic infrastructure
In reply to Marek LindnerQuoted 12 lines · On Tuesday 23 April 2013 21:39:57 Marek Lindner wrote:
main.c +12
-0+/** +* batadv_tvlv_handler_unregister - unregister tvlv handler based on the +* provided type and version (both need to match) +* @bat_priv: the bat priv with all the soft interface information +* @type: tvlv handler type to be unregistered +* @version: tvlv handler version to be unregistered +*/ +void batadv_tvlv_handler_unregister (struct batadv_priv *bat_priv, +uint8_t type,uint8_t version) +{ +struct batadv_tvlv_handler *tvlv_handler; +
main.c __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr) · line 1009
Quoted 10 lines
main.c +10
-0+ tvlv_handler =batadv_tvlv_handler_get (bat_priv, type, version); +if (!tvlv_handler) +return ; + +batadv_tvlv_handler_free_ref (tvlv_handler); +spin_lock_bh (&bat_priv->tvlv.handler_list_lock); +hlist_del_rcu (&tvlv_handler->list); +spin_unlock_bh (&bat_priv->tvlv.handler_list_lock); +batadv_tvlv_handler_free_ref (tvlv_handler); +}
Looks unsafe. How do you make sure that it is still in the list and not already already removed in the meantime? hlist_del_rcu does not re-initialize the pointers (only POISON them when CONFIG_DEBUG_LIST is activated). Thus calling hlist_del_rcu again on an object not in the list either kills other data structures or causes an Oops.
There are more *list_del* related problems of that type in your code. This is just one example I've picked.
See http://www.open-mesh.org/issues/217#note-5
Kind regards,
Sven