Author: adrian.chadd
Date: Sun Feb 22 21:56:07 2009
New Revision: 13847
Added:
playpen/LUSCA_HEAD_bgp/src/bgp.c
Modified:
playpen/LUSCA_HEAD_bgp/src/Makefile.am
playpen/LUSCA_HEAD_bgp/src/cf.data.pre
playpen/LUSCA_HEAD_bgp/src/main.c
playpen/LUSCA_HEAD_bgp/src/protos.h
playpen/LUSCA_HEAD_bgp/src/structs.h
Log:
Tie in the basic BGP code into the main cache application.
The "reload" logic is very stupid - it'll close/open the BGP session even
if its
not actually required - so its not quite production ready just yet.
Modified: playpen/LUSCA_HEAD_bgp/src/Makefile.am
==============================================================================
--- playpen/LUSCA_HEAD_bgp/src/Makefile.am (original)
+++ playpen/LUSCA_HEAD_bgp/src/Makefile.am Sun Feb 22 21:56:07 2009
@@ -118,6 +118,7 @@
acl.c \
asn.c \
authenticate.c \
+ bgp.c \
cache_cf.c \
CacheDigest.c \
cache_manager.c \
Added: playpen/LUSCA_HEAD_bgp/src/bgp.c
==============================================================================
--- (empty file)
+++ playpen/LUSCA_HEAD_bgp/src/bgp.c Sun Feb 22 21:56:07 2009
@@ -0,0 +1,48 @@
+#include "squid.h"
+
+#include "../libsqbgp/radix.h"
+#include "../libsqbgp/bgp_packet.h"
+#include "../libsqbgp/bgp_rib.h"
+#include "../libsqbgp/bgp_core.h"
+#include "../libsqbgp/bgp_conn.h"
+
+static bgp_conn_t *bc = NULL;
+
+void
+bgpStart(void)
+{
+ /* Is it configured? If not, don't bother. */
+ if (! Config.bgp.enable)
+ return;
+
+ /* Do we have a BGP instance? If not, create one */
+ if (bc == NULL) {
+ bc = bgp_conn_create();
+ bgp_set_lcl(&bc->bi, Config.bgp.local_ip, Config.bgp.local_as,
60);
+ bgp_set_rem(&bc->bi, Config.bgp.remote_as);
+ memcpy(&bc->rem_ip, &Config.bgp.remote_ip, sizeof(bc->rem_ip));
+ bc->rem_port = 179;
+ /* Kick it alive */
+ bgp_conn_begin_connect(bc);
+ }
+
+}
+
+void
+bgpReconfigure(void)
+{
+ /* Only restart the BGP session if the configuration doesn't match the
live one */
+ /* XXX for now, since I'm lazy */
+ bgpShutdown();
+ bgpStart();
+}
+
+void
+bgpShutdown(void)
+{
+ if (bc == NULL)
+ return;
+
+ bgp_conn_destroy(bc);
+ bc = NULL;
+}
Modified: playpen/LUSCA_HEAD_bgp/src/cf.data.pre
==============================================================================
--- playpen/LUSCA_HEAD_bgp/src/cf.data.pre (original)
+++ playpen/LUSCA_HEAD_bgp/src/cf.data.pre Sun Feb 22 21:56:07 2009
@@ -5921,4 +5921,50 @@
The default value (-1) means "use the legacy compile-time calculation."
DOC_END
+NAME: bgp_enable
+COMMENT: whether to run BGP or not
+TYPE: onoff
+LOC: Config.bgp.enable
+DEFAULT: off
+DOC_START
+
+DOC_END
+
+NAME: bgp_local_as
+COMMENT: local ASN
+TYPE: int
+LOC: Config.bgp.local_as
+DEFAULT: -1
+DOC_START
+
+DOC_END
+
+NAME: bgp_remote_as
+COMMENT: remote ASN
+TYPE: int
+LOC: Config.bgp.remote_as
+DEFAULT: -1
+DOC_START
+
+DOC_END
+
+NAME: bgp_local_ip
+COMMENT: local IP; BGP router identifier
+TYPE: address
+LOC: Config.bgp.local_ip
+DEFAULT: 0.0.0.0
+DOC_START
+
+DOC_END
+
+NAME: bgp_remote_ip
+COMMENT: remote IP; BGP router identifier
+TYPE: address
+LOC: Config.bgp.remote_ip
+DEFAULT: 0.0.0.0
+DOC_START
+
+DOC_END
+
+
EOF
Modified: playpen/LUSCA_HEAD_bgp/src/main.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/src/main.c (original)
+++ playpen/LUSCA_HEAD_bgp/src/main.c Sun Feb 22 21:56:07 2009
@@ -345,6 +345,7 @@
icmpOpen();
netdbInit();
asnInit();
+ bgpStart();
peerSelectInit();
carpInit();
peerSourceHashInit();
@@ -372,6 +373,10 @@
wccp2ConnectionClose();
#endif
asnFreeMemory();
+ if (shutting_down)
+ bgpShutdown();
+ if (reconfiguring)
+ bgpReconfigure();
}
static void
@@ -1229,6 +1234,7 @@
ipcacheFreeMemory();
fqdncacheFreeMemory();
asnFreeMemory();
+ bgpShutdown();
clientdbFreeMemory();
httpHeaderCleanModule();
statFreeMemory();
Modified: playpen/LUSCA_HEAD_bgp/src/protos.h
==============================================================================
--- playpen/LUSCA_HEAD_bgp/src/protos.h (original)
+++ playpen/LUSCA_HEAD_bgp/src/protos.h Sun Feb 22 21:56:07 2009
@@ -1093,5 +1093,10 @@
/* comm.c */
extern void commConnectStart(int fd, const char *, u_short, CNCB *, void
*, struct in_addr *addr);
+/* bgp.c */
+extern void bgpStart(void);
+extern void bgpShutdown(void);
+extern void bgpReconfigure(void);
+
#endif /* SQUID_PROTOS_H */
Modified: playpen/LUSCA_HEAD_bgp/src/structs.h
==============================================================================
--- playpen/LUSCA_HEAD_bgp/src/structs.h (original)
+++ playpen/LUSCA_HEAD_bgp/src/structs.h Sun Feb 22 21:56:07 2009
@@ -827,6 +827,11 @@
int n_aiops_threads;
} aiops;
#endif
+ struct {
+ struct in_addr local_ip, remote_ip;
+ int local_as, remote_as;
+ int enable;
+ } bgp;
};
struct _SquidConfig2 {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---