b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@ascom.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@ascom.ch>
Subject: [B.A.T.M.A.N.] [PATCH 05/12] batman-adv: Use route_unicast_packet() for sending own unicast packets
Date: Wed,  2 Mar 2011 18:18:34 +0100	[thread overview]
Message-ID: <1299086321-25116-6-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1299086321-25116-1-git-send-email-linus.luessing@ascom.ch>

This removes some redundancy present in unicast_send_skb(). It now
invokes route_unicast_packet() for the next hop decision and sending.

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
 routing.c        |   15 ++++++++-------
 routing.h        |    5 +++--
 soft-interface.c |    3 ++-
 unicast.c        |   39 +++++++--------------------------------
 4 files changed, 20 insertions(+), 42 deletions(-)

diff --git a/routing.c b/routing.c
index 118b841..97e99ce 100644
--- a/routing.c
+++ b/routing.c
@@ -1189,10 +1189,10 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
 	return 0;
 }
 
-int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if,
-			 uint8_t *dest, uint8_t packet_type)
+int route_unicast_packet(struct bat_priv *bat_priv, struct sk_buff *skb,
+			 struct hard_iface *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;
@@ -1259,6 +1259,7 @@ out:
 
 int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *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);
 
@@ -1273,8 +1274,8 @@ int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *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 hard_iface *recv_if)
@@ -1307,8 +1308,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *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);
 }
 
 
diff --git a/routing.h b/routing.h
index 88e8ef5..5972bf3 100644
--- a/routing.h
+++ b/routing.h
@@ -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 hard_iface *recv_if,
-			 uint8_t *dest, uint8_t packet_type);
+int route_unicast_packet(struct bat_priv *bat_priv, struct sk_buff *skb,
+			 struct hard_iface *recv_if, uint8_t *dest,
+			 uint8_t packet_type);
 int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if);
 int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
 int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if);
diff --git a/soft-interface.c b/soft-interface.c
index fdb3586..bd460b3 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -462,7 +462,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;
diff --git a/unicast.c b/unicast.c
index 2677c06..c6c465c 100644
--- a/unicast.c
+++ b/unicast.c
@@ -282,34 +282,19 @@ 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;
-	struct neigh_node *neigh_node;
-	int data_len = skb->len;
-	int ret = 1;
+	int ret = NET_RX_DROP;
 
 	/* get routing information */
 	if (is_multicast_ether_addr(ethhdr->h_dest)) {
 		orig_node = (struct orig_node *)gw_get_selected(bat_priv);
 		if (orig_node)
-			goto find_router;
+			goto route;
 	}
 
 	/* check for hna host - increases orig_node refcount */
 	orig_node = transtable_search(bat_priv, ethhdr->h_dest);
 
-find_router:
-	/**
-	 * find_router():
-	 *  - if orig_node is NULL it returns NULL
-	 *  - increases neigh_nodes refcount if found.
-	 */
-	neigh_node = find_router(bat_priv, orig_node, NULL);
-
-	if (!neigh_node)
-		goto out;
-
-	if (neigh_node->if_incoming->if_status != IF_ACTIVE)
-		goto out;
-
+route:
 	if (my_skb_head_push(skb, sizeof(struct unicast_packet)) < 0)
 		goto out;
 
@@ -323,24 +308,14 @@ find_router:
 	/* copy the destination for faster routing */
 	memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
 
-	if (atomic_read(&bat_priv->fragmentation) &&
-	    data_len + sizeof(struct unicast_packet) >
-				neigh_node->if_incoming->net_dev->mtu) {
-		ret = frag_send_skb(skb, bat_priv,
-				    neigh_node->if_incoming, neigh_node->addr);
-		goto out;
-	}
-
-	send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
-	ret = 0;
-	goto out;
+	ret = route_unicast_packet(orig_node->bat_priv, skb, NULL,
+		unicast_packet->dest, unicast_packet->header.packet_type);
 
 out:
-	if (neigh_node)
-		neigh_node_free_ref(neigh_node);
 	if (orig_node)
 		orig_node_free_ref(orig_node);
-	if (ret == 1)
+	if (ret == NET_RX_DROP)
 		kfree_skb(skb);
+
 	return ret;
 }
-- 
1.7.2.3


  parent reply	other threads:[~2011-03-02 17:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-02 17:18 [B.A.T.M.A.N.] Redundancy bonding mode patches, v2 Linus Lüssing
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 01/12] batman-adv: Remove unused hdr_size variable in route_unicast_packet() Linus Lüssing
2011-03-02 17:36   ` Marek Lindner
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 02/12] batman-adv: Add explicit batman header structure Linus Lüssing
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 03/12] batman-adv: Unify TTL handling Linus Lüssing
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 04/12] batman-adv: Make route_unicast_packet() packet_type independent Linus Lüssing
2011-03-02 17:18 ` Linus Lüssing [this message]
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 06/12] batman-adv: Avoid redundant hash_find() call for own unicast packets Linus Lüssing
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 07/12] batman-adv: Use packet lists for unicast packet sending Linus Lüssing
2011-03-03 13:17   ` Marek Lindner
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 08/12] batman-adv: Add sysfs option for enabling redundant bonding mode Linus Lüssing
2011-03-03  2:01   ` Marek Lindner
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 09/12] batman-adv: Adding redundant bonding mode transmission Linus Lüssing
2011-03-03 13:48   ` Marek Lindner
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 10/12] batman-adv: Adding unicast_safe packet reception Linus Lüssing
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 11/12] batman-adv: Generic sequence number checking for data packets Linus Lüssing
2011-03-02 17:18 ` [B.A.T.M.A.N.] [PATCH 12/12] batman-adv: Add sequence number and duplicate checks for unicasts_safe Linus Lüssing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1299086321-25116-6-git-send-email-linus.luessing@ascom.ch \
    --to=linus.luessing@ascom.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).