Skip to content

Commit

Permalink
Add memcached rlm_cache_driver
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 authored and alandekok committed Nov 22, 2014
1 parent 0874c49 commit c9d4da7
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 107 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -55,6 +55,7 @@ before_install:
libjson0-dev
libkrb5-dev
libldap2-dev
libmemcached-dev
libpam0g-dev
libpcap-dev
libpcre3-dev
Expand Down
40 changes: 35 additions & 5 deletions raddb/mods-available/cache
Expand Up @@ -23,9 +23,36 @@
cache {
# The backend datastore used to store the cache entries.
# Current datastores are
# - rbtree - An in memory, non persistent rbtree based datastore.
#
# driver = "rbtree"
# rlm_cache_rbtree - An in memory, non persistent rbtree based datastore.
# Useful for caching data locally.
# rlm_cache_memcached - A non persistent "webscale" distributed datastore.
# Useful if the cached data need to be shared between
# a cluster of RADIUS servers.
# driver = "rlm_cache_rbtree"

#
# Some drivers accept specific options, to set them a
# config section with the the name as the driver should be added
# to the cache instance.
#
# Driver specific options are:
#
# memcached {
# # Memcached configuration options, as documented here:
# # http://docs.libmemcached.org/libmemcached_configuration.html#memcached
# options = "--SERVER=localhost"
#
# pool {
# start = 5
# min = 4
# max = ${thread[pool].max_servers}
# spare = 3
# uses = 0
# lifetime = 0
# idle_timeout = 60
# }
# }


# The key used to index the cache. It is dynamically expanded
# at run time.
Expand All @@ -49,6 +76,8 @@ cache {
# If yes the following attributes will be added to the request:
# * &request:Cache-Entry-Hits - The number of times this entry
# has been retrieved.
#
# Note: Not supported by the rlm_cache_memcached module.
add_stats = no

#
Expand Down Expand Up @@ -99,10 +128,11 @@ cache {
# - The module will return "updated" if a cache entry was found.
# - The module will return "notfound" if no cache was found.
#
# &control:Cache-Merge - If present and set to 'yes' will merge
# new cache entries into the current request. Useful if results
# &control:Cache-Merge - If present and set to 'yes' will merge new
# cache entries into the current request. Useful if results
# of execs or expansions are stored directly in the cache.
#
# All runtime configuration attributes will be removed from the
# &control: list after the cache module is called.

}
13 changes: 8 additions & 5 deletions share/dictionary.freeradius.internal
Expand Up @@ -224,11 +224,6 @@ ATTRIBUTE MS-CHAP-New-NT-Password 1137 octets

ATTRIBUTE Stripped-User-Domain 1138 string
ATTRIBUTE Called-Station-SSID 1139 string
ATTRIBUTE Cache-TTL 1140 signed
ATTRIBUTE Cache-Status-Only 1141 integer
ATTRIBUTE Cache-Merge 1142 integer
ATTRIBUTE Cache-Entry-Hits 1143 integer
ATTRIBUTE Cache-Read-Only 1144 integer

VALUE Cache-Status-Only no 0
VALUE Cache-Status-Only yes 1
Expand Down Expand Up @@ -261,6 +256,14 @@ ATTRIBUTE FreeRADIUS-Response-Delay-USec 1155 integer
ATTRIBUTE REST-HTTP-Header 1160 string
ATTRIBUTE REST-HTTP-Body 1161 string

ATTRIBUTE Cache-Expires 1170 date
ATTRIBUTE Cache-Created 1171 date
ATTRIBUTE Cache-TTL 1172 signed
ATTRIBUTE Cache-Status-Only 1173 integer
ATTRIBUTE Cache-Merge 1174 integer
ATTRIBUTE Cache-Entry-Hits 1175 integer
ATTRIBUTE Cache-Read-Only 1176 integer

#
# Range: 1200-1279
# EAP-SIM (and other EAP type) weirdness.
Expand Down
117 changes: 103 additions & 14 deletions src/modules/rlm_cache/drivers/rlm_cache_memcached/configure
Expand Up @@ -1475,6 +1475,73 @@ fi
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
Expand Down Expand Up @@ -3054,7 +3121,7 @@ $as_echo "$as_me: WARNING: libmemcached headers not found. Use --with-libmemcach
sm_lib_safe=`echo "memcached" | sed 'y%./+-%__p_%'`
sm_func_safe=`echo "memcached_create" | sed 'y%./+-%__p_%'`
sm_func_safe=`echo "memcached" | sed 'y%./+-%__p_%'`
old_LIBS="$LIBS"
old_CPPFLAGS="$CPPFLAGS"
Expand All @@ -3064,17 +3131,17 @@ smart_lib_dir=
if test "x$smart_try_dir" != "x"; then
for try in $smart_try_dir; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcached_create in -lmemcached in $try" >&5
$as_echo_n "checking for memcached_create in -lmemcached in $try... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcached in -lmemcached in $try" >&5
$as_echo_n "checking for memcached in -lmemcached in $try... " >&6; }
LIBS="-lmemcached $old_LIBS"
CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
extern char memcached_create();
extern char memcached();
int
main ()
{
memcached_create()
memcached()
;
return 0;
}
Expand All @@ -3099,16 +3166,16 @@ rm -f core conftest.err conftest.$ac_objext \
fi
if test "x$smart_lib" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcached_create in -lmemcached" >&5
$as_echo_n "checking for memcached_create in -lmemcached... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcached in -lmemcached" >&5
$as_echo_n "checking for memcached in -lmemcached... " >&6; }
LIBS="-lmemcached $old_LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
extern char memcached_create();
extern char memcached();
int
main ()
{
memcached_create()
memcached()
;
return 0;
}
Expand Down Expand Up @@ -3185,17 +3252,17 @@ eval "smart_lib_dir=\"\$smart_lib_dir $DIRS\""
for try in $smart_lib_dir /usr/local/lib /opt/lib; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcached_create in -lmemcached in $try" >&5
$as_echo_n "checking for memcached_create in -lmemcached in $try... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcached in -lmemcached in $try" >&5
$as_echo_n "checking for memcached in -lmemcached in $try... " >&6; }
LIBS="-lmemcached $old_LIBS"
CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
extern char memcached_create();
extern char memcached();
int
main ()
{
memcached_create()
memcached()
;
return 0;
}
Expand Down Expand Up @@ -3225,11 +3292,33 @@ if test "x$smart_lib" != "x"; then
SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS"
fi
if test "x$ac_cv_lib_memcached_memcached_create" != "xyes"
if test "x$ac_cv_lib_memcached_memcached" != "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libmemcached libraries not found. Use --with-libmemcached-lib-dir=<path>." >&5
$as_echo "$as_me: WARNING: libmemcached libraries not found. Use --with-libmemcached-lib-dir=<path>." >&2;}
fail="libmemcached $fail"
else
for ac_func in \
memcached \
memcached_free \
memcached_get \
memcached_set \
memcached_delete \
libmemcached_check_configuration \
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
else
fail="memached functions"
fi
done
fi
targetname=rlm_cache_memcached
Expand Down
13 changes: 11 additions & 2 deletions src/modules/rlm_cache/drivers/rlm_cache_memcached/configure.ac
Expand Up @@ -84,11 +84,20 @@ if test x$with_[]modname != xno; then
smart_try_dir="$libmemcached_lib_dir"
dnl # Use a libmemcached specific function which is only
dnl # available in newer versions.
FR_SMART_CHECK_LIB([memcached], [memcached_create])
if test "x$ac_cv_lib_memcached_memcached_create" != "xyes"
FR_SMART_CHECK_LIB([memcached], [memcached])
if test "x$ac_cv_lib_memcached_memcached" != "xyes"
then
AC_MSG_WARN([libmemcached libraries not found. Use --with-libmemcached-lib-dir=<path>.])
fail="libmemcached $fail"
else
AC_CHECK_FUNCS(\
memcached \
memcached_free \
memcached_get \
memcached_set \
memcached_delete \
libmemcached_check_configuration \
,, [fail="memached functions"])
fi

targetname=modname
Expand Down

0 comments on commit c9d4da7

Please sign in to comment.