Catching errors in SQL xlat queries

Pshem Kowalczyk pshem.k at gmail.com
Thu May 26 23:59:57 CEST 2016


Hi,

We have a setup where a main frontend  cluster (3.0.11) proxies requests to
various remote radius servers.
We validate and adjust responses from those serves to match the
requirements of a particular BNGs the session is on (this is for a
DSL/fibre setup). For example if the remote radius system wants the speed
of the connection limited to a given number they reply with our own
'SV-Speed-Down' attribute and a value. We do some SQL lookups:

 update {
        &control:Tmp-String-0 := "%{frontend_sql:SELECT prefix || '#' ||
suffix FROM attrib_map, nas_type \
                                                    WHERE
nas_type.nasid='%{request:NAS-Identifier}' AND \
                                                    attrib_map.nas_type =
nas_type.type AND \
                                                    attrib_map.attribute =
'SV-Speed-Down'}"
    }

in order to figure out the actual syntax required for the particular BNG.
Then we use a regex to parse out the details:

if (&control:Tmp-String-0 =~ /([a-z-]+)#[a-0-9]+)/) {

Recently we had some issues with the DB running out of steam (and handles).
We've noticed that this didn't stop the queries from running and returning
empty results (and not matching the regex).

With the regular rlm_sql queries the module returns 'fail' if there was a
problem with the database or 'notfound' if there was nothing to return. Is
there a way to detect the 'fail' state with the xlat queries?

kind regards
Pshem


More information about the Freeradius-Users mailing list