* [B.A.T.M.A.N.] [PATCH] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
@ 2013-04-18 8:11 Martin Hundebøll
2013-04-18 10:11 ` [B.A.T.M.A.N.] [PATCHv2] " Martin Hundebøll
0 siblings, 1 reply; 7+ messages in thread
From: Martin Hundebøll @ 2013-04-18 8:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
The call to batadv_nc_skb_forward() fits better in
batadv_send_skb_to_orig(), as this is where the actual next hop is
looked up.
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
This is a patch to prepare for the merge of the next fragmentation patches,
as these will remove the current lookup of the next-hop in route_unicast_packet().
network-coding.c | 5 ++---
network-coding.h | 6 ++----
routing.c | 9 +++------
send.c | 17 +++++++++++------
4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index c93df9e..dc94b76 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -1359,18 +1359,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff *skb,
* buffer
* @skb: data skb to forward
* @neigh_node: next hop to forward packet to
- * @ethhdr: pointer to the ethernet header inside the skb
*
* Returns true if the skb was consumed (encoded packet sent) or false otherwise
*/
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
const struct net_device *netdev = neigh_node->if_incoming->soft_iface;
struct batadv_priv *bat_priv = netdev_priv(netdev);
struct batadv_unicast_packet *packet;
struct batadv_nc_path *nc_path;
+ struct ethhdr *ethhdr = eth_hdr(skb);
__be32 packet_id;
u8 *payload;
diff --git a/network-coding.h b/network-coding.h
index 4fa6d0c..85a4ec8 100644
--- a/network-coding.h
+++ b/network-coding.h
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv,
void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
void batadv_nc_init_orig(struct batadv_orig_node *orig_node);
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr);
+ struct batadv_neigh_node *neigh_node);
void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
struct sk_buff *skb);
void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct batadv_orig_node *orig_node)
}
static inline bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
return false;
}
diff --git a/routing.c b/routing.c
index 0e10720..19cf8b6 100644
--- a/routing.c
+++ b/routing.c
@@ -835,16 +835,13 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
/* decrement ttl */
unicast_packet->header.ttl--;
- /* network code packet if possible */
- if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) {
- ret = NET_RX_SUCCESS;
- } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
- ret = NET_RX_SUCCESS;
-
+ if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
/* Update stats counter */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
skb->len + ETH_HLEN);
+
+ ret = NET_RX_SUCCESS;
}
out:
diff --git a/send.c b/send.c
index ed7072a..a241a79 100644
--- a/send.c
+++ b/send.c
@@ -110,8 +110,13 @@ bool batadv_send_skb_to_orig(struct sk_buff *skb,
if (!neigh_node)
return false;
- /* route it */
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ /* try to network code the packet, if it is received on an interface
+ * (i.e. being forwarded). If the packet originates from this node or if
+ * network coding fails, then send the packet as usual.
+ */
+ if (!recv_if || !batadv_nc_skb_forward(skb, neigh_node))
+ batadv_send_skb_packet(skb, neigh_node->if_incoming,
+ neigh_node->addr);
batadv_neigh_node_free_ref(neigh_node);
@@ -122,8 +127,8 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
- if ((hard_iface->if_status == BATADV_IF_NOT_IN_USE) ||
- (hard_iface->if_status == BATADV_IF_TO_BE_REMOVED))
+ if ((hard_iface->if_status == batadv_if_not_in_use) ||
+ (hard_iface->if_status == batadv_if_to_be_removed))
return;
/* the interface gets activated here to avoid race conditions between
@@ -132,8 +137,8 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
* outdated packets (especially uninitialized mac addresses) in the
* packet queue
*/
- if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED)
- hard_iface->if_status = BATADV_IF_ACTIVE;
+ if (hard_iface->if_status == batadv_if_to_be_activated)
+ hard_iface->if_status = batadv_if_active;
bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface);
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
2013-04-18 8:11 [B.A.T.M.A.N.] [PATCH] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c Martin Hundebøll
@ 2013-04-18 10:11 ` Martin Hundebøll
2013-04-18 10:14 ` [B.A.T.M.A.N.] [PATCHv3] " Martin Hundebøll
0 siblings, 1 reply; 7+ messages in thread
From: Martin Hundebøll @ 2013-04-18 10:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
The call to batadv_nc_skb_forward() fits better in
batadv_send_skb_to_orig(), as this is where the actual next hop is
looked up.
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
v2: I should make random defines lowercase :)
network-coding.c | 5 ++---
network-coding.h | 6 ++----
routing.c | 9 +++------
send.c | 17 +++++++++++------
4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index c93df9e..dc94b76 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -1359,18 +1359,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff *skb,
* buffer
* @skb: data skb to forward
* @neigh_node: next hop to forward packet to
- * @ethhdr: pointer to the ethernet header inside the skb
*
* Returns true if the skb was consumed (encoded packet sent) or false otherwise
*/
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
const struct net_device *netdev = neigh_node->if_incoming->soft_iface;
struct batadv_priv *bat_priv = netdev_priv(netdev);
struct batadv_unicast_packet *packet;
struct batadv_nc_path *nc_path;
+ struct ethhdr *ethhdr = eth_hdr(skb);
__be32 packet_id;
u8 *payload;
diff --git a/network-coding.h b/network-coding.h
index 4fa6d0c..85a4ec8 100644
--- a/network-coding.h
+++ b/network-coding.h
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv,
void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
void batadv_nc_init_orig(struct batadv_orig_node *orig_node);
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr);
+ struct batadv_neigh_node *neigh_node);
void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
struct sk_buff *skb);
void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct batadv_orig_node *orig_node)
}
static inline bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
return false;
}
diff --git a/routing.c b/routing.c
index 0e10720..19cf8b6 100644
--- a/routing.c
+++ b/routing.c
@@ -835,16 +835,13 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
/* decrement ttl */
unicast_packet->header.ttl--;
- /* network code packet if possible */
- if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) {
- ret = NET_RX_SUCCESS;
- } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
- ret = NET_RX_SUCCESS;
-
+ if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
/* Update stats counter */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
skb->len + ETH_HLEN);
+
+ ret = NET_RX_SUCCESS;
}
out:
diff --git a/send.c b/send.c
index ed7072a..a241a79 100644
--- a/send.c
+++ b/send.c
@@ -110,8 +110,13 @@ bool batadv_send_skb_to_orig(struct sk_buff *skb,
if (!neigh_node)
return false;
- /* route it */
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ /* try to network code the packet, if it is received on an interface
+ * (i.e. being forwarded). If the packet originates from this node or if
+ * network coding fails, then send the packet as usual.
+ */
+ if (!recv_if || !batadv_nc_skb_forward(skb, neigh_node))
+ batadv_send_skb_packet(skb, neigh_node->if_incoming,
+ neigh_node->addr);
batadv_neigh_node_free_ref(neigh_node);
@@ -122,8 +127,8 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
- if ((hard_iface->if_status == BATADV_IF_NOT_IN_USE) ||
- (hard_iface->if_status == BATADV_IF_TO_BE_REMOVED))
+ if ((hard_iface->if_status == batadv_if_not_in_use) ||
+ (hard_iface->if_status == batadv_if_to_be_removed))
return;
/* the interface gets activated here to avoid race conditions between
@@ -132,8 +137,8 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
* outdated packets (especially uninitialized mac addresses) in the
* packet queue
*/
- if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED)
- hard_iface->if_status = BATADV_IF_ACTIVE;
+ if (hard_iface->if_status == batadv_if_to_be_activated)
+ hard_iface->if_status = batadv_if_active;
bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface);
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [B.A.T.M.A.N.] [PATCHv3] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
2013-04-18 10:11 ` [B.A.T.M.A.N.] [PATCHv2] " Martin Hundebøll
@ 2013-04-18 10:14 ` Martin Hundebøll
2013-04-19 12:16 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
0 siblings, 1 reply; 7+ messages in thread
From: Martin Hundebøll @ 2013-04-18 10:14 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
The call to batadv_nc_skb_forward() fits better in
batadv_send_skb_to_orig(), as this is where the actual next hop is
looked up.
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
v2: I should make random defines lowercase :)
v3: Do git add before committing and sending patches :|
network-coding.c | 5 ++---
network-coding.h | 6 ++----
routing.c | 9 +++------
send.c | 9 +++++++--
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index c93df9e..dc94b76 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -1359,18 +1359,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff *skb,
* buffer
* @skb: data skb to forward
* @neigh_node: next hop to forward packet to
- * @ethhdr: pointer to the ethernet header inside the skb
*
* Returns true if the skb was consumed (encoded packet sent) or false otherwise
*/
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
const struct net_device *netdev = neigh_node->if_incoming->soft_iface;
struct batadv_priv *bat_priv = netdev_priv(netdev);
struct batadv_unicast_packet *packet;
struct batadv_nc_path *nc_path;
+ struct ethhdr *ethhdr = eth_hdr(skb);
__be32 packet_id;
u8 *payload;
diff --git a/network-coding.h b/network-coding.h
index 4fa6d0c..85a4ec8 100644
--- a/network-coding.h
+++ b/network-coding.h
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv,
void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
void batadv_nc_init_orig(struct batadv_orig_node *orig_node);
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr);
+ struct batadv_neigh_node *neigh_node);
void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
struct sk_buff *skb);
void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct batadv_orig_node *orig_node)
}
static inline bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
return false;
}
diff --git a/routing.c b/routing.c
index 0e10720..19cf8b6 100644
--- a/routing.c
+++ b/routing.c
@@ -835,16 +835,13 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
/* decrement ttl */
unicast_packet->header.ttl--;
- /* network code packet if possible */
- if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) {
- ret = NET_RX_SUCCESS;
- } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
- ret = NET_RX_SUCCESS;
-
+ if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
/* Update stats counter */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
skb->len + ETH_HLEN);
+
+ ret = NET_RX_SUCCESS;
}
out:
diff --git a/send.c b/send.c
index ed7072a..fa8077a 100644
--- a/send.c
+++ b/send.c
@@ -110,8 +110,13 @@ bool batadv_send_skb_to_orig(struct sk_buff *skb,
if (!neigh_node)
return false;
- /* route it */
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ /* try to network code the packet, if it is received on an interface
+ * (i.e. being forwarded). If the packet originates from this node or if
+ * network coding fails, then send the packet as usual.
+ */
+ if (!recv_if || !batadv_nc_skb_forward(skb, neigh_node))
+ batadv_send_skb_packet(skb, neigh_node->if_incoming,
+ neigh_node->addr);
batadv_neigh_node_free_ref(neigh_node);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [B.A.T.M.A.N.] [PATCHv4] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
2013-04-18 10:14 ` [B.A.T.M.A.N.] [PATCHv3] " Martin Hundebøll
@ 2013-04-19 12:16 ` Martin Hundebøll
2013-04-20 11:54 ` [B.A.T.M.A.N.] [PATCHv5] " Martin Hundebøll
2013-04-20 14:01 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
0 siblings, 2 replies; 7+ messages in thread
From: Martin Hundebøll @ 2013-04-19 12:16 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
The call to batadv_nc_skb_forward() fits better in
batadv_send_skb_to_orig(), as this is where the actual next hop is
looked up.
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
v2: I should make random defines lowercase :)
v3: Do git add before committing and sending patches :|
v4: Don't count non-coded packets twice
network-coding.c | 8 ++------
network-coding.h | 6 ++----
routing.c | 9 +++------
send.c | 9 +++++++--
4 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index c93df9e..3435729 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -542,9 +542,6 @@ static bool batadv_nc_fwd_flush(struct batadv_priv *bat_priv,
return false;
/* Send packet */
- batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
- batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
- nc_packet->skb->len + ETH_HLEN);
list_del(&nc_packet->list);
batadv_nc_send_packet(nc_packet);
@@ -1359,18 +1356,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff *skb,
* buffer
* @skb: data skb to forward
* @neigh_node: next hop to forward packet to
- * @ethhdr: pointer to the ethernet header inside the skb
*
* Returns true if the skb was consumed (encoded packet sent) or false otherwise
*/
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
const struct net_device *netdev = neigh_node->if_incoming->soft_iface;
struct batadv_priv *bat_priv = netdev_priv(netdev);
struct batadv_unicast_packet *packet;
struct batadv_nc_path *nc_path;
+ struct ethhdr *ethhdr = eth_hdr(skb);
__be32 packet_id;
u8 *payload;
diff --git a/network-coding.h b/network-coding.h
index 4fa6d0c..85a4ec8 100644
--- a/network-coding.h
+++ b/network-coding.h
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv,
void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
void batadv_nc_init_orig(struct batadv_orig_node *orig_node);
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr);
+ struct batadv_neigh_node *neigh_node);
void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
struct sk_buff *skb);
void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct batadv_orig_node *orig_node)
}
static inline bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
return false;
}
diff --git a/routing.c b/routing.c
index 0e10720..19cf8b6 100644
--- a/routing.c
+++ b/routing.c
@@ -835,16 +835,13 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
/* decrement ttl */
unicast_packet->header.ttl--;
- /* network code packet if possible */
- if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) {
- ret = NET_RX_SUCCESS;
- } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
- ret = NET_RX_SUCCESS;
-
+ if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
/* Update stats counter */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
skb->len + ETH_HLEN);
+
+ ret = NET_RX_SUCCESS;
}
out:
diff --git a/send.c b/send.c
index ed7072a..fa8077a 100644
--- a/send.c
+++ b/send.c
@@ -110,8 +110,13 @@ bool batadv_send_skb_to_orig(struct sk_buff *skb,
if (!neigh_node)
return false;
- /* route it */
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ /* try to network code the packet, if it is received on an interface
+ * (i.e. being forwarded). If the packet originates from this node or if
+ * network coding fails, then send the packet as usual.
+ */
+ if (!recv_if || !batadv_nc_skb_forward(skb, neigh_node))
+ batadv_send_skb_packet(skb, neigh_node->if_incoming,
+ neigh_node->addr);
batadv_neigh_node_free_ref(neigh_node);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [B.A.T.M.A.N.] [PATCHv5] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
2013-04-19 12:16 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
@ 2013-04-20 11:54 ` Martin Hundebøll
2013-04-20 14:16 ` Marek Lindner
2013-04-20 14:01 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
1 sibling, 1 reply; 7+ messages in thread
From: Martin Hundebøll @ 2013-04-20 11:54 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
The call to batadv_nc_skb_forward() fits better in
batadv_send_skb_to_orig(), as this is where the actual next hop is
looked up.
To let the caller of batadv_send_skb_to_orig() know wether the skb is
transmitted, buffered or failed, the return value is changed from
boolean to int.
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
v2: I should make random defines lowercase
v3: Do git add before committing and sending patches :|
v4: Don't count non-coded packets twice
v5: Change return value to do correct counting
network-coding.c | 5 ++---
network-coding.h | 6 ++----
routing.c | 23 +++++++++++++----------
send.c | 27 +++++++++++++++++++--------
send.h | 6 +++---
translation-table.c | 12 +++++++-----
unicast.c | 2 +-
vis.c | 7 ++++---
8 files changed, 51 insertions(+), 37 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index 2a996bf..65af447 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -1359,18 +1359,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff *skb,
* buffer
* @skb: data skb to forward
* @neigh_node: next hop to forward packet to
- * @ethhdr: pointer to the ethernet header inside the skb
*
* Returns true if the skb was consumed (encoded packet sent) or false otherwise
*/
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
const struct net_device *netdev = neigh_node->if_incoming->soft_iface;
struct batadv_priv *bat_priv = netdev_priv(netdev);
struct batadv_unicast_packet *packet;
struct batadv_nc_path *nc_path;
+ struct ethhdr *ethhdr = eth_hdr(skb);
__be32 packet_id;
u8 *payload;
diff --git a/network-coding.h b/network-coding.h
index 4fa6d0c..85a4ec8 100644
--- a/network-coding.h
+++ b/network-coding.h
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv,
void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
void batadv_nc_init_orig(struct batadv_orig_node *orig_node);
bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr);
+ struct batadv_neigh_node *neigh_node);
void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
struct sk_buff *skb);
void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct batadv_orig_node *orig_node)
}
static inline bool batadv_nc_skb_forward(struct sk_buff *skb,
- struct batadv_neigh_node *neigh_node,
- struct ethhdr *ethhdr)
+ struct batadv_neigh_node *neigh_node)
{
return false;
}
diff --git a/routing.c b/routing.c
index 0e10720..5c8a552 100644
--- a/routing.c
+++ b/routing.c
@@ -285,7 +285,7 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
icmp_packet->msg_type = BATADV_ECHO_REPLY;
icmp_packet->header.ttl = BATADV_TTL;
- if (batadv_send_skb_to_orig(skb, orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = NET_RX_SUCCESS;
out:
@@ -333,7 +333,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
icmp_packet->header.ttl = BATADV_TTL;
- if (batadv_send_skb_to_orig(skb, orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = NET_RX_SUCCESS;
out:
@@ -410,7 +410,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
icmp_packet->header.ttl--;
/* route it */
- if (batadv_send_skb_to_orig(skb, orig_node, recv_if))
+ if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP)
ret = NET_RX_SUCCESS;
out:
@@ -775,7 +775,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
struct batadv_neigh_node *neigh_node = NULL;
struct batadv_unicast_packet *unicast_packet;
struct ethhdr *ethhdr = eth_hdr(skb);
- int ret = NET_RX_DROP;
+ int res, ret = NET_RX_DROP;
struct sk_buff *new_skb;
unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@ -835,16 +835,19 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
/* decrement ttl */
unicast_packet->header.ttl--;
- /* network code packet if possible */
- if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) {
- ret = NET_RX_SUCCESS;
- } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
- ret = NET_RX_SUCCESS;
+ res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
- /* Update stats counter */
+ /* translate transmit result into receive result */
+ if (res == NET_XMIT_SUCCESS) {
+ /* skb was transmitted and consumed */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
skb->len + ETH_HLEN);
+
+ ret = NET_RX_SUCCESS;
+ } else if (res == NET_XMIT_POLICED) {
+ /* skb was buffered and consumed */
+ ret = NET_RX_SUCCESS;
}
out:
diff --git a/send.c b/send.c
index ce69f45..e9ff8d8 100644
--- a/send.c
+++ b/send.c
@@ -96,26 +96,37 @@ send_skb_err:
* host, NULL can be passed as recv_if and no interface alternating is
* attempted.
*
- * Returns TRUE on success; FALSE otherwise.
+ * Returns NET_XMIT_SUCCESS on success, NET_XMIT_DROP on failure, or
+ * NET_XMIT_POLICED if the skb is buffered for later transmit.
*/
-bool batadv_send_skb_to_orig(struct sk_buff *skb,
- struct batadv_orig_node *orig_node,
- struct batadv_hard_iface *recv_if)
+int batadv_send_skb_to_orig(struct sk_buff *skb,
+ struct batadv_orig_node *orig_node,
+ struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = orig_node->bat_priv;
struct batadv_neigh_node *neigh_node;
+ int ret = NET_XMIT_DROP;
/* batadv_find_router() increases neigh_nodes refcount if found. */
neigh_node = batadv_find_router(bat_priv, orig_node, recv_if);
if (!neigh_node)
- return false;
+ return ret;
- /* route it */
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ /* try to network code the packet, if it is received on an interface
+ * (i.e. being forwarded). If the packet originates from this node or if
+ * network coding fails, then send the packet as usual.
+ */
+ if (recv_if && batadv_nc_skb_forward(skb, neigh_node)) {
+ ret = NET_XMIT_POLICED;
+ } else {
+ batadv_send_skb_packet(skb, neigh_node->if_incoming,
+ neigh_node->addr);
+ ret = NET_XMIT_SUCCESS;
+ }
batadv_neigh_node_free_ref(neigh_node);
- return true;
+ return ret;
}
void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
diff --git a/send.h b/send.h
index 38e662f..e7b1788 100644
--- a/send.h
+++ b/send.h
@@ -23,9 +23,9 @@
int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
const uint8_t *dst_addr);
-bool batadv_send_skb_to_orig(struct sk_buff *skb,
- struct batadv_orig_node *orig_node,
- struct batadv_hard_iface *recv_if);
+int batadv_send_skb_to_orig(struct sk_buff *skb,
+ struct batadv_orig_node *orig_node,
+ struct batadv_hard_iface *recv_if);
void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface);
int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
const struct sk_buff *skb,
diff --git a/translation-table.c b/translation-table.c
index e272f68..5948a21 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -1713,7 +1713,7 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX);
- if (batadv_send_skb_to_orig(skb, dst_orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, dst_orig_node, NULL) != NET_XMIT_DROP)
ret = 0;
out:
@@ -1737,7 +1737,7 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv,
struct batadv_orig_node *req_dst_orig_node;
struct batadv_orig_node *res_dst_orig_node = NULL;
uint8_t orig_ttvn, req_ttvn, ttvn;
- int ret = false;
+ int res, ret = false;
unsigned char *tt_buff;
bool full_table;
uint16_t tt_len, tt_tot;
@@ -1832,7 +1832,9 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv,
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
- if (batadv_send_skb_to_orig(skb, res_dst_orig_node, NULL))
+ res = batadv_send_skb_to_orig(skb, res_dst_orig_node, NULL);
+
+ if (res != NET_XMIT_DROP)
ret = true;
goto out;
@@ -1947,7 +1949,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv,
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
- if (batadv_send_skb_to_orig(skb, orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = true;
goto out;
@@ -2260,7 +2262,7 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX);
- if (batadv_send_skb_to_orig(skb, orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = 0;
out:
diff --git a/unicast.c b/unicast.c
index 0bb3b59..dc8b5d4 100644
--- a/unicast.c
+++ b/unicast.c
@@ -464,7 +464,7 @@ find_router:
goto out;
}
- if (batadv_send_skb_to_orig(skb, orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = 0;
out:
diff --git a/vis.c b/vis.c
index 94eaeb5..4983340 100644
--- a/vis.c
+++ b/vis.c
@@ -697,7 +697,7 @@ static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node;
struct batadv_vis_packet *packet;
struct sk_buff *skb;
- uint32_t i;
+ uint32_t i, res;
packet = (struct batadv_vis_packet *)info->skb_packet->data;
@@ -724,7 +724,8 @@ static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv,
if (!skb)
continue;
- if (!batadv_send_skb_to_orig(skb, orig_node, NULL))
+ res = batadv_send_skb_to_orig(skb, orig_node, NULL);
+ if (res == NET_XMIT_DROP)
kfree_skb(skb);
}
rcu_read_unlock();
@@ -748,7 +749,7 @@ static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv,
if (!skb)
goto out;
- if (!batadv_send_skb_to_orig(skb, orig_node, NULL))
+ if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP)
kfree_skb(skb);
out:
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv4] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
2013-04-19 12:16 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
2013-04-20 11:54 ` [B.A.T.M.A.N.] [PATCHv5] " Martin Hundebøll
@ 2013-04-20 14:01 ` Martin Hundebøll
1 sibling, 0 replies; 7+ messages in thread
From: Martin Hundebøll @ 2013-04-20 14:01 UTC (permalink / raw)
To: b.a.t.m.a.n
On 2013-04-19 14:16, Martin Hundebøll wrote:
> The call to batadv_nc_skb_forward() fits better in
> batadv_send_skb_to_orig(), as this is where the actual next hop is
> looked up.
>
> Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
> ---
>
> v2: I should make random defines lowercase :)
> v3: Do git add before committing and sending patches :|
> v4: Don't count non-coded packets twice
>
> network-coding.c | 8 ++------
> network-coding.h | 6 ++----
> routing.c | 9 +++------
> send.c | 9 +++++++--
> 4 files changed, 14 insertions(+), 18 deletions(-)
Okay, I include this patch as a part of the fragmentation series, as
this is why it is needed.
--
Kind Regards
Martin Hundebøll
Frederiks Allé 99, 1.th
8000 Aarhus C
Denmark
+45 61 65 54 61
martin@hundeboll.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv5] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c
2013-04-20 11:54 ` [B.A.T.M.A.N.] [PATCHv5] " Martin Hundebøll
@ 2013-04-20 14:16 ` Marek Lindner
0 siblings, 0 replies; 7+ messages in thread
From: Marek Lindner @ 2013-04-20 14:16 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
On Saturday, April 20, 2013 19:54:39 Martin Hundebøll wrote:
> The call to batadv_nc_skb_forward() fits better in
> batadv_send_skb_to_orig(), as this is where the actual next hop is
> looked up.
>
> To let the caller of batadv_send_skb_to_orig() know wether the skb is
> transmitted, buffered or failed, the return value is changed from
> boolean to int.
>
> Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
> ---
>
> v2: I should make random defines lowercase
> v3: Do git add before committing and sending patches :|
> v4: Don't count non-coded packets twice
> v5: Change return value to do correct counting
>
> network-coding.c | 5 ++---
> network-coding.h | 6 ++----
> routing.c | 23 +++++++++++++----------
> send.c | 27 +++++++++++++++++++--------
> send.h | 6 +++---
> translation-table.c | 12 +++++++-----
> unicast.c | 2 +-
> vis.c | 7 ++++---
> 8 files changed, 51 insertions(+), 37 deletions(-)
Applied in revision ae72fda.
Thanks,
Marek
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-04-20 14:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18 8:11 [B.A.T.M.A.N.] [PATCH] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c Martin Hundebøll
2013-04-18 10:11 ` [B.A.T.M.A.N.] [PATCHv2] " Martin Hundebøll
2013-04-18 10:14 ` [B.A.T.M.A.N.] [PATCHv3] " Martin Hundebøll
2013-04-19 12:16 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
2013-04-20 11:54 ` [B.A.T.M.A.N.] [PATCHv5] " Martin Hundebøll
2013-04-20 14:16 ` Marek Lindner
2013-04-20 14:01 ` [B.A.T.M.A.N.] [PATCHv4] " Martin Hundebøll
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox