batman-adv: refine API calls for unicast transmissions of SKBs
PATCH v2 1/1 batman-adv: refine API calls for unicast transmissions of SKBs
With this patch the functions batadv_send_skb_unicast() and batadv_send_skb_unicast_4addr() are further refined into batadv_send_skb_via_tt(), batadv_send_skb_via_tt_4addr() and batadv_send_skb_via_gw(). This way we avoid any "guessing" about where to send a packet in the unicast forwarding methods and let the callers decide.
This is going to be useful for the upcoming multicast related patches in particular.
---
Made changes according to Marek's and Antonio's feedback on irc:
* changed _tt*()/_gw() to _via_tt*()/_via_gw()
* changed comment about return value:
using defines "NET_RX_SUCCESS"/"NET_RX_DROP"
* changed a "ret = 0" to "ret = NET_RX_SUCCESS"
And added the changes Antonio suggested via eMail.
distributed-arp-table.c | 8 ++--- send.c | 83 +++++++++++++++++++++++++++++++++++++---------- send.h | 51 +++++++++++++++++------------ soft-interface.c | 6 +++- 4 files changed, 104 insertions(+), 44 deletions(-)
distributed-arp-table.c +4 -4
@@ -1026,11 +1026,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,* that a node not using the 4addr packet format doesn't support it. */ if (hdr_size ==sizeof (struct batadv_unicast_4addr_packet )) - err =batadv_send_skb_unicast_4addr (bat_priv, skb_new, -BATADV_P_DAT_CACHE_REPLY , - vid); + err =batadv_send_skb_via_tt_4addr (bat_priv, skb_new, +BATADV_P_DAT_CACHE_REPLY , + vid);else - err =batadv_send_skb_unicast (bat_priv, skb_new, vid); + err =batadv_send_skb_via_tt (bat_priv, skb_new, vid);if (!err) {batadv_inc_counter (bat_priv,BATADV_CNT_DAT_CACHED_REPLY_TX );
send.c +65 -18
114 lines not on this page · raw message
send.h +30 -21
75 lines not on this page · raw message
soft-interface.c +5 -1
@@ -289,7 +289,11 @@ static int batadv_interface_tx(struct sk_buff *skb,batadv_dat_snoop_outgoing_arp_reply (bat_priv, skb); - ret =batadv_send_skb_unicast (bat_priv, skb, vid); +if (is_multicast_ether_addr (ethhdr->h_dest)) + ret =batadv_send_skb_via_gw (bat_priv, skb, vid); +else + ret =batadv_send_skb_via_tt (bat_priv, skb, vid); +if (ret !=0 ) goto dropped_freed; }
Signature · 1 line
1.7.10.4
Hi Linus,
Quoted 9 lines · Linus Lüssing
distributed-arp-table.c +0
-1@@ -1026,11 +1026,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,* that a node not using the 4addr packet format doesn't support it. */ if (hdr_size ==sizeof (struct batadv_unicast_4addr_packet )) - err = batadv_send_skb_unicast_4addr(bat_priv, skb_new,
distributed-arp-table.c bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, · line 1035
Quoted 10 lines
distributed-arp-table.c +4
-3-BATADV_P_DAT_CACHE_REPLY , - vid); + err =batadv_send_skb_via_tt_4addr (bat_priv, skb_new, +BATADV_P_DAT_CACHE_REPLY , + vid); else - err =batadv_send_skb_unicast (bat_priv, skb_new, vid); + err =batadv_send_skb_via_tt (bat_priv, skb_new, vid);if (!err) {
now that the functions do not return 0 or 1 anymore this check should be changed to "ret != DROP". We can't assume that the SUCCESS define is 0.
Quoted 16 lines
distributed-arp-table.c +0
-0batadv_inc_counter (bat_priv,BATADV_CNT_DAT_CACHED_REPLY_TX );send.c +1
-1@@ -235,36 +235,32 @@ out: }/** -* batadv_send_generic_unicast_skb - send an skb as unicast +* batadv_send_skb_unicast - encapsulate and send an skb via unicast * @bat_priv: the bat priv with all the soft interface information * @skb: payload to send * @packet_type: the batman unicast packet type to use * @packet_subtype: the unicast 4addr packet subtype (only relevant for unicast * 4addr packets)
send.c out: · line 252
Quoted 10 lines
send.c +7
-1+* @orig_node: the originator to send the packet to * @vid: the vid to be used to search the translation table * -* Returns 1 in case of error or 0 otherwise. +* Wrap the given skb into a batman-adv unicast or unicast-4addr header +* depending on whether BATADV_UNICAST or BATADV_UNICAST_4ADDR was supplied +* as packet_type. Then send this frame to the given orig_node and release a +* reference to this orig_node. +* +* Return NET_RX_DROP in case of error or NET_RX_SUCCESS otherwise.
This function is in the TX path, therefore you should use NET_XMIT_SUCCESS/DROP rather than their RX version.
Same comments apply to the other functions.
Cheers,
Signature · 4 lines
Antonio Quartulli ..each of us alone is worth nothing.. Ernesto "Che" Guevara