diff options
author | Ondrej Filip <feela@network.cz> | 2012-05-11 00:01:29 +0200 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2012-05-11 00:01:29 +0200 |
commit | 72b2db8db7534c52e928618410ec1f18787752c8 (patch) | |
tree | 7eee7f4c26a36f72e0700e9e5d78056f5329f85c /sysdep/bsd | |
parent | 2795700c3158fa52b6cf957e9d0b9ad4a27c67a5 (diff) | |
parent | 95616c820248018f4999972cad315f2da60e4960 (diff) |
Merge branch 'master' of ssh://git.nic.cz/bird
Diffstat (limited to 'sysdep/bsd')
-rw-r--r-- | sysdep/bsd/Modules | 7 | ||||
-rw-r--r-- | sysdep/bsd/krt-iface.h | 25 | ||||
-rw-r--r-- | sysdep/bsd/krt-scan.h | 22 | ||||
-rw-r--r-- | sysdep/bsd/krt-set.h | 17 | ||||
-rw-r--r-- | sysdep/bsd/krt-sock.c | 137 | ||||
-rw-r--r-- | sysdep/bsd/krt-sock.h | 42 | ||||
-rw-r--r-- | sysdep/bsd/krt-sys.h | 49 |
7 files changed, 105 insertions, 194 deletions
diff --git a/sysdep/bsd/Modules b/sysdep/bsd/Modules index 84abffdb..3729587d 100644 --- a/sysdep/bsd/Modules +++ b/sysdep/bsd/Modules @@ -1,6 +1,3 @@ -krt-scan.h -krt-iface.h -sysio.h -krt-set.h krt-sock.c -krt-sock.h +krt-sys.h +sysio.h diff --git a/sysdep/bsd/krt-iface.h b/sysdep/bsd/krt-iface.h deleted file mode 100644 index 7f0d52bd..00000000 --- a/sysdep/bsd/krt-iface.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * BIRD -- Unix Kernel Socket Route Syncer -- Dummy Include File - * - * (c) 2004 Ondrej Filip <feela@network.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#ifndef _BIRD_KRT_IFACE_H_ -#define _BIRD_KRT_IFACE_H_ - -/* - * We don't have split iface/scan/set parts. See krt-sock.h. - */ - -struct krt_if_params { -}; - -struct krt_if_status { -}; - -static inline int kif_params_same(struct krt_if_params *old UNUSED, struct krt_if_params *new UNUSED) { return 1; } -static inline void kif_copy_params(struct krt_if_params *dest UNUSED, struct krt_if_params *src UNUSED) { } - -#endif diff --git a/sysdep/bsd/krt-scan.h b/sysdep/bsd/krt-scan.h deleted file mode 100644 index 19cd930d..00000000 --- a/sysdep/bsd/krt-scan.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * BIRD -- *BSD Kernel Route Syncer -- Scanning - * - * (c) 2004 Ondrej Filip <feela@network.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#ifndef _BIRD_KRT_SCAN_H_ -#define _BIRD_KRT_SCAN_H_ - -struct krt_scan_params { -}; - -struct krt_scan_status { - list temp_ifs; /* Temporary interfaces */ -}; - -static inline int krt_scan_params_same(struct krt_scan_params *o UNUSED, struct krt_scan_params *n UNUSED) { return 1; } -static inline void krt_scan_copy_params(struct krt_scan_params *d UNUSED, struct krt_scan_params *s UNUSED) { } - -#endif diff --git a/sysdep/bsd/krt-set.h b/sysdep/bsd/krt-set.h deleted file mode 100644 index b5453d4b..00000000 --- a/sysdep/bsd/krt-set.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * BIRD -- Unix Kernel Socket Route Syncer -- Dummy Include File - * - * (c) 2004 Ondrej Filip <feela@network.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#ifndef _BIRD_KRT_SET_H_ -#define _BIRD_KRT_SET_H_ - -/* - * We don't have split iface/scan/set parts. See krt-sock.h. - */ -#include "lib/krt-sock.h" - -#endif diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c index 9ca36d83..e970d6bd 100644 --- a/sysdep/bsd/krt-sock.c +++ b/sysdep/bsd/krt-sock.c @@ -33,7 +33,19 @@ #include "lib/string.h" #include "lib/socket.h" -int rt_sock = 0; + +#ifndef RTAX_MAX +#define RTAX_MAX 8 +#endif + +struct ks_msg +{ + struct rt_msghdr rtm; + struct sockaddr_storage buf[RTAX_MAX]; +}; + + +static int rt_sock = 0; int krt_capable(rte *e) @@ -189,8 +201,8 @@ krt_sock_send(int cmd, rte *e) } void -krt_set_notify(struct krt_proto *p UNUSED, net *n, rte *new, rte *old, - struct ea_list *eattrs UNUSED) +krt_replace_rte(struct krt_proto *p UNUSED, net *n, rte *new, rte *old, + struct ea_list *eattrs UNUSED) { int err = 0; @@ -206,45 +218,6 @@ krt_set_notify(struct krt_proto *p UNUSED, net *n, rte *new, rte *old, n->n.flags &= ~KRF_SYNC_ERROR; } -static int -krt_set_hook(sock *sk, int size UNUSED) -{ - struct ks_msg msg; - int l = read(sk->fd, (char *)&msg, sizeof(msg)); - - if(l <= 0) - log(L_ERR "krt-sock: read failed"); - else - krt_read_msg((struct proto *)sk->data, &msg, 0); - - return 0; -} - -void -krt_set_start(struct krt_proto *x, int first UNUSED) -{ - sock *sk_rt; - static int ks_open_tried = 0; - - if (ks_open_tried) - return; - - ks_open_tried = 1; - - DBG("KRT: Opening kernel socket\n"); - - if( (rt_sock = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0) - die("Cannot open kernel socket for routes"); - - sk_rt = sk_new(krt_pool); - sk_rt->type = SK_MAGIC; - sk_rt->rx_hook = krt_set_hook; - sk_rt->fd = rt_sock; - sk_rt->data = x; - if (sk_open(sk_rt)) - bug("krt-sock: sk_open failed"); -} - #define SKIP(ARG...) do { DBG("KRT: Ignoring route - " ARG); return; } while(0) static void @@ -648,32 +621,6 @@ krt_read_msg(struct proto *p, struct ks_msg *msg, int scan) } } -void -krt_scan_construct(struct krt_config *c UNUSED) -{ -} - -void -krt_scan_preconfig(struct config *c UNUSED) -{ -} - -void -krt_scan_postconfig(struct krt_config *c UNUSED) -{ -} - -void -krt_scan_start(struct krt_proto *x, int first UNUSED) -{ - init_list(&x->scan.temp_ifs); -} - -void -krt_scan_shutdown(struct krt_proto *x UNUSED, int last UNUSED) -{ -} - static void krt_sysctl_scan(struct proto *p, pool *pool, byte **buf, size_t *bl, int cmd) { @@ -732,13 +679,13 @@ static size_t krt_buflen = 32768; static size_t kif_buflen = 4096; void -krt_scan_fire(struct krt_proto *p) +krt_do_scan(struct krt_proto *p) { krt_sysctl_scan((struct proto *)p, p->krt_pool, &krt_buffer, &krt_buflen, NET_RT_DUMP); } void -krt_if_scan(struct kif_proto *p) +kif_do_scan(struct kif_proto *p) { struct proto *P = (struct proto *)p; if_start_update(); @@ -746,14 +693,47 @@ krt_if_scan(struct kif_proto *p) if_end_update(); } +static int +krt_sock_hook(sock *sk, int size UNUSED) +{ + struct ks_msg msg; + int l = read(sk->fd, (char *)&msg, sizeof(msg)); + + if(l <= 0) + log(L_ERR "krt-sock: read failed"); + else + krt_read_msg((struct proto *)sk->data, &msg, 0); + + return 0; +} void -krt_set_construct(struct krt_config *c UNUSED) +krt_sys_start(struct krt_proto *x, int first UNUSED) { + sock *sk_rt; + static int ks_open_tried = 0; + + if (ks_open_tried) + return; + + ks_open_tried = 1; + + DBG("KRT: Opening kernel socket\n"); + + if( (rt_sock = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0) + die("Cannot open kernel socket for routes"); + + sk_rt = sk_new(krt_pool); + sk_rt->type = SK_MAGIC; + sk_rt->rx_hook = krt_sock_hook; + sk_rt->fd = rt_sock; + sk_rt->data = x; + if (sk_open(sk_rt)) + bug("krt-sock: sk_open failed"); } void -krt_set_shutdown(struct krt_proto *x UNUSED, int last UNUSED) +krt_sys_shutdown(struct krt_proto *x UNUSED, int last UNUSED) { if (!krt_buffer) return; @@ -762,23 +742,14 @@ krt_set_shutdown(struct krt_proto *x UNUSED, int last UNUSED) krt_buffer = NULL; } -void -krt_if_io_init(void) -{ -} - -void -krt_if_construct(struct kif_config *c UNUSED) -{ -} void -krt_if_start(struct kif_proto *p UNUSED) +kif_sys_start(struct kif_proto *p UNUSED) { } void -krt_if_shutdown(struct kif_proto *p UNUSED) +kif_sys_shutdown(struct kif_proto *p UNUSED) { if (!kif_buffer) return; diff --git a/sysdep/bsd/krt-sock.h b/sysdep/bsd/krt-sock.h deleted file mode 100644 index aab639c4..00000000 --- a/sysdep/bsd/krt-sock.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * BIRD -- Unix Kernel Route Syncer -- Setting - * - * (c) 2004 Ondrej Filip <feela@network.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#ifndef _BIRD_KRT_SOCK_H_ -#define _BIRD_KRT_SOCK_H_ - -#include <sys/socket.h> -#include <net/route.h> -#include "lib/socket.h" - -#ifndef RTAX_MAX -#define RTAX_MAX 8 -#endif - - -struct ks_msg -{ - struct rt_msghdr rtm; - struct sockaddr_storage buf[RTAX_MAX]; -}; - - - -extern int krt_set_sock; - -struct krt_set_params { -}; - -struct krt_set_status { -}; - -static inline int krt_set_params_same(struct krt_set_params *o UNUSED, struct krt_set_params *n UNUSED) { return 1; } -static inline void krt_set_copy_params(struct krt_set_params *d UNUSED, struct krt_set_params *s UNUSED) { } - -void krt_read_msg(struct proto *p, struct ks_msg *msg, int scan); - -#endif diff --git a/sysdep/bsd/krt-sys.h b/sysdep/bsd/krt-sys.h new file mode 100644 index 00000000..88915dde --- /dev/null +++ b/sysdep/bsd/krt-sys.h @@ -0,0 +1,49 @@ +/* + * BIRD -- *BSD Kernel Route Syncer + * + * (c) 2004 Ondrej Filip <feela@network.cz> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifndef _BIRD_KRT_SYS_H_ +#define _BIRD_KRT_SYS_H_ + + +/* Kernel interfaces */ + +struct kif_params { +}; + +struct kif_status { +}; + + +static inline void kif_sys_init(struct kif_proto *p UNUSED) { } +static inline int kif_sys_reconfigure(struct kif_proto *p UNUSED, struct kif_config *n UNUSED, struct kif_config *o UNUSED) { return 1; } + +static inline void kif_sys_preconfig(struct config *c UNUSED) { } +static inline void kif_sys_postconfig(struct kif_config *c UNUSED) { } +static inline void kif_sys_init_config(struct kif_config *c UNUSED) { } +static inline void kif_sys_copy_config(struct kif_config *d UNUSED, struct kif_config *s UNUSED) { } + + +/* Kernel routes */ + +struct krt_params { +}; + +struct krt_status { +}; + + +static inline void krt_sys_init(struct krt_proto *p UNUSED) { } +static inline int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n UNUSED, struct krt_config *o UNUSED) { return 1; } + +static inline void krt_sys_preconfig(struct config *c UNUSED) { } +static inline void krt_sys_postconfig(struct krt_config *c UNUSED) { } +static inline void krt_sys_init_config(struct krt_config *c UNUSED) { } +static inline void krt_sys_copy_config(struct krt_config *d UNUSED, struct krt_config *s UNUSED) { } + + +#endif |