projects
/
l2tpns.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b6cfeb
)
improved load balancing algorithm.
author
fendo
<fendo@bi12info.com>
Tue, 3 Sep 2013 13:02:22 +0000
(15:02 +0200)
committer
fendo
<fendo@bi12info.com>
Tue, 3 Sep 2013 13:02:22 +0000
(15:02 +0200)
grpsess.c
patch
|
blob
|
history
diff --git
a/grpsess.c
b/grpsess.c
index
a4b63ab
..
ccaa27c
100644
(file)
--- a/
grpsess.c
+++ b/
grpsess.c
@@
-25,6
+25,14
@@
union grp_iphash {
groupidt gnextgrpid = 0;
groupidt gnextgrpid = 0;
+typedef struct
+{
+ sessionidt sid_loaddist[0x10000];
+}
+local_group;
+
+local_group *grp_local = NULL; // Array of local_group structures.
+
// Find gruop by IP, < 1 for not found
//
// Confusingly enough, this 'ip' must be
// Find gruop by IP, < 1 for not found
//
// Confusingly enough, this 'ip' must be
@@
-42,14
+50,6
@@
static groupidt grp_lookup_ipmap(in_addr_t ip)
return h[*a].grp;
}
return h[*a].grp;
}
-typedef struct
-{
- sessionidt sid_loaddist[0x10000];
-}
-local_group;
-
-local_group *grp_local = NULL; // Array of local_group structures.
-
//
// Take an IP address in HOST byte order and
// add it to the grouid by IP cache.
//
// Take an IP address in HOST byte order and
// add it to the grouid by IP cache.
@@
-513,6
+513,7
@@
static void grp_uncache_ipsession(groupidt g, sessionidt s)
}
}
}
}
+uint16_t guint16_index_loadlist;
// return the next session can be used on the group
sessionidt grp_getnextsession(groupidt g, in_addr_t ip, in_addr_t ip_src)
{
// return the next session can be used on the group
sessionidt grp_getnextsession(groupidt g, in_addr_t ip, in_addr_t ip_src)
{
@@
-539,7
+540,8
@@
sessionidt grp_getnextsession(groupidt g, in_addr_t ip, in_addr_t ip_src)
coutgrp_delta = session[s2].cout - grpsession[g].sesslist[i].prev_coutgrp;
grpsession[g].sesslist[i].prev_coutgrp = session[s2].cout;
coutgrp_delta = session[s2].cout - grpsession[g].sesslist[i].prev_coutgrp;
grpsession[g].sesslist[i].prev_coutgrp = session[s2].cout;
- grpsession[g].sesslist[i].tx_rate = coutgrp_delta/ltime_changed;
+ txrate = (txrate + (coutgrp_delta/ltime_changed)) >> 1;
+ grpsession[g].sesslist[i].tx_rate = txrate;
txrate = grpsession[g].sesslist[i].tx_rate/grpsession[g].sesslist[i].weight;
if (txrate < mintxrate)
txrate = grpsession[g].sesslist[i].tx_rate/grpsession[g].sesslist[i].weight;
if (txrate < mintxrate)
@@
-583,19
+585,14
@@
sessionidt grp_getnextsession(groupidt g, in_addr_t ip, in_addr_t ip_src)
if (g != grp_groupbysession(s))
{
// This session does not belong to this group
if (g != grp_groupbysession(s))
{
// This session does not belong to this group
- LOG(
2
, s, session[s].tunnel, "Warning, the session does not belong to group %d\n", g);
+ LOG(
3
, s, session[s].tunnel, "Warning, the session does not belong to group %d\n", g);
s = 0;
grp_local[g].sid_loaddist[ai] = 0;
}
s = 0;
grp_local[g].sid_loaddist[ai] = 0;
}
- else if (s == grpsession[g].smax)
- {
- s = grpsession[g].smin;
- grp_local[g].sid_loaddist[ai] = s;
- grpsession[g].smax = 0;
- }
else if ( (session[s].ppp.phase > Establish) &&
(time_now - session[s].last_packet <= (config->echo_timeout + 1)) )
{
else if ( (session[s].ppp.phase > Establish) &&
(time_now - session[s].last_packet <= (config->echo_timeout + 1)) )
{
+ grp_local[g].sid_loaddist[guint16_index_loadlist++] = 0;
return s;
}
else
return s;
}
else