diff options
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.c | 56 | ||||
-rw-r--r-- | accel-pppd/extra/ipv6pool.c | 6 | ||||
-rw-r--r-- | accel-pppd/extra/pppd_compat.c | 4 | ||||
-rw-r--r-- | accel-pppd/logs/log_pgsql.c | 4 | ||||
-rw-r--r-- | accel-pppd/logs/log_syslog.c | 4 | ||||
-rw-r--r-- | accel-pppd/memdebug.c | 4 | ||||
-rw-r--r-- | accel-pppd/radius/packet.c | 4 | ||||
-rw-r--r-- | accel-pppd/session.c | 6 | ||||
-rw-r--r-- | accel-pppd/triton/mempool.c | 9 | ||||
-rw-r--r-- | accel-pppd/triton/spinlock.h | 22 | ||||
-rw-r--r-- | accel-pppd/triton/triton.c | 7 | ||||
-rw-r--r-- | accel-pppd/utils.c | 3 |
12 files changed, 70 insertions, 59 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index b4c962c..21042b7 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -241,34 +241,42 @@ void dhcpv4_print_packet(struct dhcpv4_packet *pack, int relay, void (*print)(co print("[DHCPv4 %s%s xid=%x ", relay ? "relay " : "", msg_name[pack->msg_type - 1], pack->hdr->xid); - if (pack->hdr->ciaddr) + if (pack->hdr->ciaddr) { + in_addr_t addr = ntohl(pack->hdr->ciaddr); print("ciaddr=%i.%i.%i.%i ", - pack->hdr->ciaddr & 0xff, - (pack->hdr->ciaddr >> 8) & 0xff, - (pack->hdr->ciaddr >> 16) & 0xff, - (pack->hdr->ciaddr >> 24) & 0xff); - - if (pack->hdr->yiaddr) + (addr >> 24) & 0xff, + (addr >> 16) & 0xff, + (addr >> 8) & 0xff, + addr & 0xff); + } + + if (pack->hdr->yiaddr) { + in_addr_t addr = ntohl(pack->hdr->yiaddr); print("yiaddr=%i.%i.%i.%i ", - pack->hdr->yiaddr & 0xff, - (pack->hdr->yiaddr >> 8) & 0xff, - (pack->hdr->yiaddr >> 16) & 0xff, - (pack->hdr->yiaddr >> 24) & 0xff); - - if (pack->hdr->siaddr) + (addr >> 24) & 0xff, + (addr >> 16) & 0xff, + (addr >> 8) & 0xff, + addr & 0xff); + } + + if (pack->hdr->siaddr) { + in_addr_t addr = ntohl(pack->hdr->siaddr); print("siaddr=%i.%i.%i.%i ", - pack->hdr->siaddr & 0xff, - (pack->hdr->siaddr >> 8) & 0xff, - (pack->hdr->siaddr >> 16) & 0xff, - (pack->hdr->siaddr >> 24) & 0xff); - - if (pack->hdr->giaddr) + (addr >> 24) & 0xff, + (addr >> 16) & 0xff, + (addr >> 8) & 0xff, + addr & 0xff); + } + + if (pack->hdr->giaddr) { + in_addr_t addr = ntohl(pack->hdr->giaddr); print("giaddr=%i.%i.%i.%i ", - pack->hdr->giaddr & 0xff, - (pack->hdr->giaddr >> 8) & 0xff, - (pack->hdr->giaddr >> 16) & 0xff, - (pack->hdr->giaddr >> 24) & 0xff); - + (addr >> 24) & 0xff, + (addr >> 16) & 0xff, + (addr >> 8) & 0xff, + addr & 0xff); + } + print("chaddr=%02x:%02x:%02x:%02x:%02x:%02x ", pack->hdr->chaddr[0], pack->hdr->chaddr[1], diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c index 5a9dde9..9db7b40 100644 --- a/accel-pppd/extra/ipv6pool.c +++ b/accel-pppd/extra/ipv6pool.c @@ -31,7 +31,7 @@ struct dppool_item_t static LIST_HEAD(ippool); static LIST_HEAD(dppool); -static spinlock_t pool_lock = SPINLOCK_INITIALIZER; +static spinlock_t pool_lock; static struct ipdb_t ipdb; static void generate_ippool(struct in6_addr *addr, int mask, int prefix_len) @@ -190,7 +190,9 @@ static void ippool_init(void) { struct conf_sect_t *s = conf_get_section("ipv6-pool"); struct conf_option_t *opt; - + + spinlock_init(&pool_lock); + if (!s) return; diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 7bdf597..e005e8b 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -430,6 +430,7 @@ static void write_radattr(struct pppd_compat_pd *pd, struct rad_packet_t *pack) FILE *f; char *fname1, *fname2 = NULL; int i; + in_addr_t addr; fname1 = _malloc(PATH_MAX); if (!fname1) { @@ -478,7 +479,8 @@ static void write_radattr(struct pppd_compat_pd *pd, struct rad_packet_t *pack) fprintf(f, "\n"); break; case ATTR_TYPE_IPADDR: - fprintf(f, "%i.%i.%i.%i\n", attr->val.ipaddr & 0xff, (attr->val.ipaddr >> 8) & 0xff, (attr->val.ipaddr >> 16) & 0xff, (attr->val.ipaddr >> 24) & 0xff); + addr = ntohl(attr->val.ipaddr); + fprintf(f, "%i.%i.%i.%i\n", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); break; case ATTR_TYPE_DATE: fprintf(f, "%lu\n", attr->val.date); diff --git a/accel-pppd/logs/log_pgsql.c b/accel-pppd/logs/log_pgsql.c index 1a62a9a..0c2152e 100644 --- a/accel-pppd/logs/log_pgsql.c +++ b/accel-pppd/logs/log_pgsql.c @@ -36,7 +36,7 @@ static PGconn *conn; static LIST_HEAD(msg_queue); static int queue_size; static int sleeping = 0; -static spinlock_t queue_lock = SPINLOCK_INITIALIZER; +static spinlock_t queue_lock; static char *log_buf; static int need_close; @@ -284,6 +284,8 @@ static void init(void) { char *opt; + spinlock_init(&queue_lock); + opt = conf_get_opt("log-pgsql", "conninfo"); if (!opt) return; diff --git a/accel-pppd/logs/log_syslog.c b/accel-pppd/logs/log_syslog.c index cbab525..b0b079a 100644 --- a/accel-pppd/logs/log_syslog.c +++ b/accel-pppd/logs/log_syslog.c @@ -25,7 +25,7 @@ static struct triton_context_t syslog_ctx = { static LIST_HEAD(msg_queue); static int queue_size; static int sleeping = 1; -static spinlock_t queue_lock = SPINLOCK_INITIALIZER; +static spinlock_t queue_lock; static char *log_buf; static int need_close; static char *ident; @@ -180,6 +180,8 @@ static void load_config() static void init(void) { + spinlock_init(&queue_lock); + log_buf = malloc(LOG_MAX_SIZE + 1); load_config(); diff --git a/accel-pppd/memdebug.c b/accel-pppd/memdebug.c index 1f4af36..4b37400 100644 --- a/accel-pppd/memdebug.c +++ b/accel-pppd/memdebug.c @@ -40,7 +40,7 @@ struct mem_t }; static LIST_HEAD(mem_list); -static spinlock_t mem_list_lock = SPINLOCK_INITIALIZER; +static spinlock_t mem_list_lock; static struct mem_t *_md_malloc(size_t size, const char *fname, int line) { @@ -242,6 +242,8 @@ void __export md_check(void *ptr) static void __init init(void) { + spinlock_init(&mem_list_lock); + signal(36, siginfo); signal(37, siginfo2); } diff --git a/accel-pppd/radius/packet.c b/accel-pppd/radius/packet.c index ace9f6e..5bff60a 100644 --- a/accel-pppd/radius/packet.c +++ b/accel-pppd/radius/packet.c @@ -284,6 +284,7 @@ void rad_packet_print(struct rad_packet_t *pack, struct rad_server_t *s, void (* uint64_t ifid; uint16_t u16[4]; } ifid_u; + in_addr_t addr; if (s) print("[RADIUS(%i) ", s->id); @@ -348,7 +349,8 @@ void rad_packet_print(struct rad_packet_t *pack, struct rad_server_t *s, void (* print("\"%s\"", attr->val.string); break; case ATTR_TYPE_IPADDR: - print("%i.%i.%i.%i", attr->val.ipaddr & 0xff, (attr->val.ipaddr >> 8) & 0xff, (attr->val.ipaddr >> 16) & 0xff, (attr->val.ipaddr >> 24) & 0xff); + addr = ntohl(attr->val.ipaddr); + print("%i.%i.%i.%i", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); break; case ATTR_TYPE_IFID: ifid_u.ifid = attr->val.ifid; diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 267b960..d8ee6dd 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -43,7 +43,7 @@ int __export urandom_fd; int __export ap_shutdown; #if __WORDSIZE == 32 -static spinlock_t seq_lock = SPINLOCK_INITIALIZER; +static spinlock_t seq_lock; #endif static long long unsigned seq; static struct timespec seq_ts; @@ -419,6 +419,10 @@ static void init(void) { FILE *f; +#if __WORDSIZE == 32 + spinlock_init(&seq_lock); +#endif + sock_fd = socket(AF_INET, SOCK_DGRAM, 0); if (sock_fd < 0) { perror("socket"); diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c index 1ee00f3..4a3ec8b 100644 --- a/accel-pppd/triton/mempool.c +++ b/accel-pppd/triton/mempool.c @@ -53,8 +53,8 @@ struct _item_t }; static LIST_HEAD(pools); -static spinlock_t pools_lock = SPINLOCK_INITIALIZER; -static spinlock_t mmap_lock = SPINLOCK_INITIALIZER; +static spinlock_t pools_lock; +static spinlock_t mmap_lock; static void *mmap_ptr; static void *mmap_endptr; @@ -343,7 +343,10 @@ static void __init init(void) { sigset_t set; sigfillset(&set); - + + spinlock_init(&pools_lock); + spinlock_init(&mmap_lock); + struct sigaction sa = { .sa_handler = sigclean, .sa_mask = set, diff --git a/accel-pppd/triton/spinlock.h b/accel-pppd/triton/spinlock.h index b09d827..529719e 100644 --- a/accel-pppd/triton/spinlock.h +++ b/accel-pppd/triton/spinlock.h @@ -1,26 +1,7 @@ #ifndef __TRITON_SPINLOCK_H #define __TRITON_SPINLOCK_H -#if defined(FUTEX_SPINLOCK) - -/*#include <unistd.h> -#include <sys/syscall.h> -#include <linux/futex.h> -typedef volatile int __attribute__((aligned)) spinlock_t; -static inline void _spin_lock(spinlock_t *l) -{ - syscall(SYS_futex, l, FUTEX_WAIT, r, NULL, NULL, 0); -} -static inline void _spin_unlock(spinlock_t *l) -{ - syscall(SYS_futex, l, FUTEX_WAKE, 2, NULL, NULL, 0); -} -#define spin_lock(l) _spin_lock(l) -#define spin_unlock(l) _spin_unlock(l) -#define SPINLOCK_INITIALIZER 1 -#define spinlock_init(l) {*(l)=1;}*/ - -#elif defined(GCC_SPINLOCK) +#if defined(GCC_SPINLOCK) typedef volatile int __attribute__((aligned)) spinlock_t; #define spin_lock(l) {while(__sync_lock_test_and_set(l,1));} @@ -34,7 +15,6 @@ typedef volatile int __attribute__((aligned)) spinlock_t; typedef pthread_spinlock_t spinlock_t; #define spin_lock(l) pthread_spin_lock(l) #define spin_unlock(l) pthread_spin_unlock(l) -#define SPINLOCK_INITIALIZER 1 #define spinlock_init(l) pthread_spin_init(l, 0) #endif diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index b0adf57..05cbf21 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -16,13 +16,13 @@ int thread_count = 2; int thread_count_max = 200; int max_events = 64; -static spinlock_t threads_lock = SPINLOCK_INITIALIZER; +static spinlock_t threads_lock; static LIST_HEAD(threads); static LIST_HEAD(sleep_threads); static LIST_HEAD(ctx_queue); -static spinlock_t ctx_list_lock = SPINLOCK_INITIALIZER; +static spinlock_t ctx_list_lock; static LIST_HEAD(ctx_list); static LIST_HEAD(init_list); @@ -581,6 +581,9 @@ void __export triton_register_init(int order, void (*func)(void)) int __export triton_init(const char *conf_file) { + spinlock_init(&threads_lock); + spinlock_init(&ctx_list_lock); + ctx_pool = mempool_create(sizeof(struct _triton_context_t)); call_pool = mempool_create(sizeof(struct _triton_ctx_call_t)); diff --git a/accel-pppd/utils.c b/accel-pppd/utils.c index 45e8709..81b4c99 100644 --- a/accel-pppd/utils.c +++ b/accel-pppd/utils.c @@ -12,7 +12,8 @@ extern int urandom_fd; void __export u_inet_ntoa(in_addr_t addr, char *str) { - sprintf(str, "%i.%i.%i.%i", addr & 0xff, (addr >> 8) & 0xff, (addr >> 16) & 0xff, (addr >> 24) & 0xff); + addr = ntohl(addr); + sprintf(str, "%i.%i.%i.%i", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); } int __export u_readlong(long int *dst, const char *src, |