[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1411573940-14079-23-git-send-email-ahmed@gandi.net>
Date: Wed, 24 Sep 2014 17:52:18 +0200
From: Ahmed Amamou <ahmed@...di.net>
To: netdev@...r.kernel.org
Cc: william@...di.net, f.cachereul@...halink.fr,
Ahmed Amamou <ahmed@...di.net>,
Kamel Haddadou <kamel@...di.net>
Subject: [RFC PATCH 22/24] net: rbridge: Add rbr_fwd
add rbridge forward function
packets arriving to rbr_fwd should be already encapsulated and correct egress
and ingress nickname should be already assigned
rbr_fwd function will assign correct source and destination outer MAC addresses
according to which port will send the frame and next hop to reach
the engress nickname
Nexthope to reach the egress will be found in node database
Signed-off-by: Ahmed Amamou <ahmed@...di.net>
Signed-off-by: Kamel Haddadou <kamel@...di.net>
Signed-off-by: William Dauchy <william@...di.net>
Signed-off-by: François Cachereul <f.cachereul@...halink.fr>
---
net/bridge/rbridge/rbr.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/net/bridge/rbridge/rbr.c b/net/bridge/rbridge/rbr.c
index 8aa5182..39aa816c 100644
--- a/net/bridge/rbridge/rbr.c
+++ b/net/bridge/rbridge/rbr.c
@@ -177,6 +177,51 @@ static bool add_header(struct sk_buff *skb, uint16_t ingressnick,
return 0;
}
+static void rbr_fwd(struct net_bridge_port *p, struct sk_buff *skb,
+ uint16_t adj_nick, u16 vid)
+{
+ struct rbr_node *adj;
+ struct trill_hdr *trh;
+ struct ethhdr *outerethhdr;
+ struct net *net = dev_net(p->br->dev);
+ struct net_device *outdev;
+
+ adj = rbr_find_node(p->br->rbr, adj_nick);
+ outdev = __dev_get_by_index(net, adj->rbr_ni->linkid);
+ if (!outdev) {
+ pr_warn_ratelimited("rbr_fwd: cannot find source port device for forwrding\n");
+ goto dest_fwd_fail;
+ }
+ if (unlikely(adj == NULL)) {
+ pr_warn_ratelimited
+ ("rbr_fwd: unable to find adjacent RBridge\n");
+ goto dest_fwd_fail;
+ }
+
+ trh = (struct trill_hdr *)skb->data;
+ trillhdr_dec_hopcount(trh);
+ outerethhdr = eth_hdr(skb);
+
+ /* change outer ether header */
+ /* bridge become the source_port address in outeretherhdr */
+ memcpy(outerethhdr->h_source, p->br->dev->dev_addr, ETH_ALEN);
+ /* dist port become dest address in outeretherhdr */
+ memcpy(outerethhdr->h_dest, adj->rbr_ni->adjsnpa, ETH_ALEN);
+ rbr_node_put(adj);
+ /* set Bridge as source device */
+ skb->dev = p->br->dev;
+ br_forward(br_port_get_rcu(outdev), skb, NULL);
+
+ return;
+
+ dest_fwd_fail:
+ if (likely(p && p->br))
+ p->br->dev->stats.tx_dropped++;
+ kfree_skb(skb);
+ return;
+}
+
+
static void rbr_encaps(struct sk_buff *skb, uint16_t egressnick, u16 vid)
{
uint16_t local_nick;
@@ -236,7 +281,7 @@ static void rbr_encaps(struct sk_buff *skb, uint16_t egressnick, u16 vid)
} else {
if (unlikely(add_header(skb, local_nick, egressnick, 0)))
goto encaps_drop;
- /* TODO simple forwarding */
+ rbr_fwd(p, skb, egressnick, vid);
}
return;
@@ -382,7 +427,7 @@ static void rbr_recv(struct sk_buff *skb, u16 vid)
rbr_decaps(p, skb, trhsize, vid);
} else if (likely(trill_get_hopcount(trill_flags))) {
br_fdb_update(p->br, p, srcaddr, vid, false);
- /* TODO simple forwarding */
+ rbr_fwd(p, skb, trh->th_egressnick, vid);
} else {
pr_warn_ratelimited
("rbr_recv: hop count limit reached\n");
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists