Skip to content

Commit 0ef3c77

Browse files
author
chris
committed
o Checkpoint decap code.
o Checkpoint IPC code. o Set tunnel MTU appropriately. o Set up tunnel interface, routes, and address appropriately.
1 parent f22296b commit 0ef3c77

22 files changed

+576
-245
lines changed

lispd_tuntap/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LOCAL_SRC_FILES = cmdline.c lispd.c lispd_config.c lispd_syslog.c \
1515
patricia/patricia.c lispd_map_request.c cksum.c \
1616
lispd_events.c lispd_db.c lispd_map_reply.c \
1717
lispd_timers.c lispd_if.c tables.c lispd_tuntap.c \
18-
lispd_encap.c
18+
lispd_encap.c lispd_decap.c lispd_ipc.c
1919
LOCAL_C_FLAGS += -g
2020
LOCAL_C_INCLUDES := external/openssl/include/
2121
LOCAL_STATIC_LIBRARIES := libconfuse

lispd_tuntap/lispd.c

Lines changed: 8 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <sys/types.h>
3636
#include <pthread.h>
3737
#include <sched.h>
38-
#include <sys/un.h>
3938
#include <errno.h>
4039

4140
#include "lispd.h"
@@ -48,6 +47,7 @@
4847
#include "lispd_syslog.h"
4948
#include "lispd_map_register.h"
5049
#include "lispd_timers.h"
50+
#include "lispd_ipc.h"
5151
#include "tables.h"
5252
#include "version.h"
5353

@@ -86,6 +86,7 @@ void init(void) {
8686
lispd_config.instance_id = 0;
8787
lispd_config.use_instance_id = FALSE;
8888
lispd_config.use_location = FALSE;
89+
lispd_config.tun_mtu = 0;
8990
}
9091

9192
void dump_fatal_error(void) {
@@ -227,130 +228,6 @@ void die(int exitcode)
227228
exit(exitcode);
228229
}
229230

230-
#define LISP_DCACHE_PATH_MAX 100
231-
#define LISP_DCACHE_FILE "/data/data/com.le.lispmon/lispd_dcache"
232-
233-
int make_dsock_addr(const char *dsock_name, struct sockaddr_un *dsock_addr, socklen_t *dsock_len)
234-
{
235-
int namelen = strlen(dsock_name);
236-
237-
if ( namelen >= ( (int)sizeof(dsock_addr->sun_path) - 1 ) ) {
238-
log_msg(ERROR, "namelen greater than allowed");
239-
return -1;
240-
}
241-
242-
strcpy(dsock_addr->sun_path, dsock_name);
243-
244-
dsock_addr->sun_family = AF_LOCAL;
245-
dsock_len = strlen(dsock_addr->sun_path) + sizeof(dsock_addr->sun_family);
246-
247-
return 0;
248-
}
249-
250-
#define MAX_IPC_COMMAND_LEN 128
251-
void * handle_dcache_requests(void *arg)
252-
{
253-
struct sockaddr_un dsock_addr;
254-
socklen_t dsock_len;
255-
int dsock_fd, dclient_fd;
256-
char *nonce, addr_buf[128], *msg = NULL, prefix_len[10], cmd[MAX_IPC_COMMAND_LEN];
257-
int msize;
258-
259-
unlink(LISP_DCACHE_FILE);
260-
261-
memset((char *)&dsock_addr, 0 ,sizeof(struct sockaddr_un));
262-
263-
if ( make_dsock_addr(LISP_DCACHE_FILE, &dsock_addr, &dsock_len) < 0 ) {
264-
log_msg(ERROR, "make_dsock failed");
265-
return NULL;
266-
}
267-
268-
if ( (dsock_fd = socket(AF_UNIX, SOCK_STREAM, 0) ) < 0) {
269-
log_msg(ERROR, "socket creation failed %s", strerror(errno));
270-
return NULL;
271-
}
272-
273-
if ( ( bind(dsock_fd, (struct sockaddr *)&dsock_addr, sizeof(struct sockaddr_un)) ) != 0 ) {
274-
log_msg(ERROR, "bind call failed %s", strerror(errno));
275-
return NULL;
276-
}
277-
278-
if ( listen(dsock_fd, 1) != 0 ) {
279-
log_msg(ERROR, "listen failed %s", strerror(errno));
280-
return NULL;
281-
}
282-
283-
log_msg(INFO, "Listening on domain socket");
284-
285-
while (1) {
286-
287-
if ( ( dclient_fd = accept(dsock_fd, (struct sockaddr *)&dsock_addr, &dsock_len) ) == -1 ) {
288-
log_msg(ERROR, "accept call failed %s", strerror(errno));
289-
return NULL;
290-
}
291-
292-
if ( recv(dclient_fd, cmd, MAX_IPC_COMMAND_LEN, 0) < 0 ) {
293-
log_msg(INFO, "recv call failed, %s", strerror(errno));
294-
return NULL;
295-
}
296-
297-
log_msg(INFO, "Received command %s", cmd);
298-
299-
if ( strcmp(cmd, "DCACHE") == 0 ) {
300-
301-
log_msg(INFO, "Got connection request for dcache.");
302-
303-
datacache_elt_t *elt, *prev;
304-
305-
elt = datacache->head;
306-
while (elt) {
307-
nonce = lisp_print_nonce(elt->nonce);
308-
inet_ntop(elt->eid_prefix.afi, &(elt->eid_prefix.address), addr_buf, sizeof(addr_buf));
309-
sprintf(prefix_len, "%d", elt->prefix_length);
310-
if (msg)
311-
free(msg);
312-
msize = sizeof(addr_buf) + strlen(nonce) + strlen(prefix_len) + 1;
313-
msg = (char *)malloc(sizeof(char)*msize);
314-
sprintf(msg, "%s#%s#%s", addr_buf, prefix_len, nonce);
315-
log_msg(INFO, "dcache entry: %s", msg);
316-
if ( ( send(dclient_fd, msg, 200, 0) ) < 0 ) {
317-
log_msg(ERROR, "send error %s", strerror(errno));
318-
return NULL;
319-
}
320-
elt = elt->next;
321-
}
322-
323-
close(dclient_fd);
324-
}
325-
else if ( strcmp(cmd, "CCACHE") == 0 ) {
326-
327-
log_msg(INFO, "Got connection request for clear_cache");
328-
log_msg(INFO, "Clearing the Map Cache");
329-
clear_map_cache();
330-
331-
close(dclient_fd);
332-
}
333-
else if ( strstr(cmd, "LOCATION") ) {
334-
335-
log_msg(INFO, "Got location information update");
336-
close(dclient_fd);
337-
}
338-
}
339-
340-
return 0;
341-
}
342-
343-
void listen_on_well_known_port()
344-
{
345-
pthread_t dcache_t;
346-
347-
if ( pthread_create(&dcache_t, NULL, handle_dcache_requests, NULL) != 0 ) {
348-
log_msg(ERROR, "thread creation failed %s", strerror(errno));
349-
return;
350-
}
351-
pthread_detach(dcache_t);
352-
}
353-
354231

355232
int main(int argc, char **argv)
356233
{
@@ -447,11 +324,6 @@ int main(int argc, char **argv)
447324

448325
create_tables();
449326

450-
if (create_tun() < 0) {
451-
log_msg(FATAL, " exiting...");
452-
exit(EXIT_FAILURE);
453-
}
454-
455327
if (build_event_socket() == 0)
456328
{
457329
log_msg(FATAL, " exiting...");
@@ -468,6 +340,11 @@ int main(int argc, char **argv)
468340
die(EXIT_FAILURE);
469341
}
470342

343+
if (tuntap_create_tun() < 0) {
344+
log_msg(FATAL, " exiting...");
345+
die(EXIT_FAILURE);
346+
}
347+
471348
/*
472349
* set up syslog now, checking to see if we're daemonizing...
473350
*/
@@ -491,7 +368,7 @@ int main(int argc, char **argv)
491368

492369
clear_map_cache();
493370

494-
// listen_on_well_known_port();
371+
listen_on_well_known_port();
495372

496373
dump_info_file();
497374
event_loop();

lispd_tuntap/lispd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
#include <sys/ioctl.h>
3333
#include <syslog.h>
3434
#include <sys/param.h>
35-
#include <sys/socket.h>
3635
#include <time.h>
37-
#include <sys/types.h>
3836
#include <unistd.h>
3937
#include "lisp_ipc.h"
4038
#include "linux/netlink.h"

lispd_tuntap/lispd_config.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "lispd_config.h"
1616
#include "lispd_util.h"
1717
#include "lispd_if.h"
18+
#include "lispd_tuntap.h"
1819

1920
lispd_config_t lispd_config;
2021

@@ -113,6 +114,7 @@ int handle_lispd_config_file(void)
113114
CFG_STR("override-dns-primary", 0, CFGF_NONE),
114115
CFG_STR("override-dns-secondary", 0, CFGF_NONE),
115116
CFG_STR("instance-id", 0, CFGF_NONE),
117+
CFG_INT("tun-mtu", TUN_OVERRIDE_MTU, CFGF_NONE),
116118
CFG_END()
117119
};
118120

@@ -135,6 +137,8 @@ int handle_lispd_config_file(void)
135137
/*
136138
* lispd config options
137139
*/
140+
if ((ret = cfg_getint(cfg, "tun-mtu")))
141+
lispd_config.tun_mtu = ret;
138142
if ((ret = cfg_getint(cfg, "map-request-retries")))
139143
lispd_config.map_request_retries = ret;
140144
if ((ret = cfg_getint(cfg, "rloc-probe-retries")))

lispd_tuntap/lispd_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ typedef struct {
5353
unsigned int instance_id;
5454
char use_instance_id;
5555
char use_location;
56+
unsigned int tun_mtu; /* MTU Override for TUN/TAP */
5657
} lispd_config_t;
5758

5859
extern lispd_config_t lispd_config;

0 commit comments

Comments
 (0)