Hi,
I recently setup routing on my gateways with the lcr module. I encounter a small problem, quoting from the README: "Matching gateways are then ordered for forwarding purpose (1) according to longest user part match, (2) according to gateway's priority, and (3) randomly." But in fact, and according to the code, the ordering is done firstly on the smallest user part match.
Here is a patch, if what I'm say is correct:
--- openser-1.0.1-tls/modules/lcr/lcr_mod.c 2005-10-28 12:30:13.000000000 +0200 +++ openser-1.0.1-tls-new/modules/lcr/lcr_mod.c 2006-04-07 14:41:35.000000000 +0200 @@ -715,7 +715,7 @@ from_uri = get_from(_m)->uri; }
- q_len = snprintf(query, MAX_QUERY_SIZE, "SELECT %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s FROM %.*s, %.*s WHERE '%.*s' LIKE %.*s.%.*s AND '%.*s' LIKE CONCAT(%.*s.%.*s, '%%') AND %.*s.%.*s = %.*s.%.*s ORDER BY CHAR_LENGTH(%.*s.%.*s), %.*s.%.*s DESC, RAND()", + q_len = snprintf(query, MAX_QUERY_SIZE, "SELECT %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s FROM %.*s, %.*s WHERE '%.*s' LIKE %.*s.%.*s AND '%.*s' LIKE CONCAT(%.*s.%.*s, '%%') AND %.*s.%.*s = %.*s.%.*s ORDER BY CHAR_LENGTH(%.*s.%.*s) DESC, %.*s.%.*s DESC, RAND()", gw_table.len, gw_table.s, ip_addr_col.len, ip_addr_col.s, gw_table.len, gw_table.s, port_col.len, port_col.s, gw_table.len, gw_table.s, uri_scheme_col.len, uri_scheme_col.s,
Regards, Nicolas
Nicolas Olivier writes:
But in fact, and according to the code, the ordering is done firstly on the smallest user part match.
nicolas,
do you have a test case that results in trying first a gw group with shorter prefix?
have you read from the code on what happens after the mysql query? the thing is that routes are put into avps in reverse priority order so that the last one put will be the one with highest priority.
-- juha
Hi,
My mistake, the records in my lcr table were wrong.
Sorry about that.
Nicolas
Juha Heinanen wrote:
Nicolas Olivier writes:
But in fact, and according to the code, the ordering is done firstly on the smallest user part match.
nicolas,
do you have a test case that results in trying first a gw group with shorter prefix?
have you read from the code on what happens after the mysql query? the thing is that routes are put into avps in reverse priority order so that the last one put will be the one with highest priority.
-- juha