Skip to contentSkip to conversation

sctp related routing cache question

Lksctp-developers Gui Jianfeng 1 participant 1 message May 8, 2008 SCTP protocol

lore
Share & tools
lore
#0 lore raw

Thanks wei,
With this patch,only one dst entry has been created, it is reused. problem solved.

Quoted 133 lines · Wei Yongjun

Hi all:

Maybe this patch can resolve this problem.

Quoted 50 lines · Gui Jianfeng
Quoted 42 lines · Neil Horman
Quoted 34 lines · Vlad Yasevich

Actually there is another cache entry created.

Quoted 10 lines · Neil Horman
Quoted 8 lines · Gui Jianfeng

Hi everyone,
Consider the following scenario:

Machine A Machine B
(10.0.0.1) (10.0.0.2)

           Echo request
     --------------->

Routing cache I(nput)

Quoted 8 lines
Quoted 8 lines
       Echo reply
         <--------------  Routing cache A created(src key:10.0.0.2)
       INIT CHUNK
     <--------------  Routing cache B created(src key:0)

Question is whether it is possible to use "Routing cache A" for sending INIT rather
then create a new "Routing cache B".

Quoted 10 lines

This doesn't really have much to do with SCTP at all, given that the routing
cache operates exclusively on the network header bits (ip src:dst:tos, etc).
Given that the destination entries are a hash of ip source, ip destination, tos,
and a few other bits, the short answer is no, outgoing frames and incomming
frames will have separate dst entries, and thats by design.

Quoted 6 lines

As Neil stated, if the sctp association uses the same src:dst:tos as well as the same
outgoing interface, then the cache entry will be reused. So, in theory it's possible.

Quoted 5 lines

In theory yes, but when replying the src and dst addresses are reversed, which
causes the src:dst:tos hash to change, meaning another dst entry will be created, or am I missing something here?

Quoted 4 lines

Neil,
Do you mean they have different hash keys, so there must be two
different dst entry to be created?

[PATCH] SCTP: lookup output route with addresses bind to assoc first while src address not specified

Change to used addresses which bind to the association first to search route while search output route with source address not specified.

Now sctp_v4_get_dst() do this thing if source address not specified:
1. Lookup route with the addresses bind to the association. If found, return this route.
2. Lookup route with unspecified address.

net/sctp/protocol.c 2008-05-01 14:25:15.000000000 -0400 renamed from net/sctp/protocol.c 2008-04-18 09:00:58.000000000 -0400 +21 -17
@@ -449,6 +449,27 @@ static struct dst_entry *sctp_v4_get_dst
    }
    if (saddr)
        fl.fl4_src = saddr->v4.sin_addr.s_addr;
+    else if (asoc) {
+        bp = &asoc->base.bind_addr;
+
+        /* Walk through the bind address list and try to get a dst that
+         * matches a bind address as the source address.
+         */
+        rcu_read_lock();
+        list_for_each_entry_rcu(laddr, &bp->address_list, list) {
+            if (!laddr->valid)
+                continue;
+            if ((laddr->state = SCTP_ADDR_SRC) &&
+                (AF_INET = laddr->a.sa.sa_family)) {
+                fl.fl4_src = laddr->a.v4.sin_addr.s_addr;
+                if (!ip_route_output_key(&init_net, &rt, &fl)) {
+                    dst = &rt->u.dst;
+                    goto out_unlock;
+                }
+            }
+        }
+        memset(&fl.fl4_src, 0x0, sizeof(fl.fl4_src));
+    }
 
    SCTP_DEBUG_PRINTK("%s: DST:%u.%u.%u.%u, SRC:%u.%u.%u.%u - ",
              __FUNCTION__, NIPQUAD(fl.fl4_dst),
@@ -487,23 +508,6 @@ static struct dst_entry *sctp_v4_get_dst
        dst = NULL;
    }
 
-    /* Walk through the bind address list and try to get a dst that
-     * matches a bind address as the source address.
-     */
-    rcu_read_lock();
-    list_for_each_entry_rcu(laddr, &bp->address_list, list) {
-        if (!laddr->valid)
-            continue;
-        if ((laddr->state = SCTP_ADDR_SRC) &&
-            (AF_INET = laddr->a.sa.sa_family)) {
-            fl.fl4_src = laddr->a.v4.sin_addr.s_addr;
-            if (!ip_route_output_key(&init_net, &rt, &fl)) {
-                dst = &rt->u.dst;
-                goto out_unlock;
-            }
-        }
-    }
-

out_unlock:

    rcu_read_unlock();

out:

Signature · 2 lines
Regards
Gui Jianfeng