summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog23
-rw-r--r--lib/command.c2
-rw-r--r--lib/log.c2
-rw-r--r--lib/log.h2
-rw-r--r--lib/md5.c2
-rw-r--r--lib/md5.h2
-rw-r--r--lib/memtypes.awk2
-rw-r--r--lib/memtypes.c3
-rw-r--r--lib/route_types.awk2
-rw-r--r--lib/sockopt.c85
-rw-r--r--lib/sockopt.h31
-rw-r--r--lib/sockunion.c8
-rw-r--r--lib/str.h2
-rw-r--r--lib/stream.c4
-rw-r--r--lib/stream.h4
-rw-r--r--lib/workqueue.c16
-rw-r--r--lib/workqueue.h3
-rw-r--r--lib/zassert.h2
-rw-r--r--lib/zebra.h1
19 files changed, 110 insertions, 86 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index da0fa8ca..688c44f7 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,26 @@
+2008-07-21 Paul Jakma <paul.jakma@sun.com>
+
+ * sockunion.c: ifdef out various places that converted
+ v4mapped sockets to pure v4. Doesn't seem necessary at all,
+ presumably a workaround for now historical inet_ntop bugs (?)
+
+2008-07-21 Michael H. Warfield <mhw@wittsend.com>
+ YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
+
+ * sockopt.{c,h}: (sockopt_tcp_signature) Add TCP-MD5SIG support.
+
+2008-06-07 Paul Jakma <paul@jakma.org>
+
+ * stream.{c,h}: (stream_{put,write}) add const qualifier to source
+ argument. Change u_char to void *.
+
+2008-06-02 Denis Ovsienko
+
+ * workqueue.[ch]: completely drop WQ_AIM_HEAD flag and
+ work_queue_aim_head() function, they aren't needed any more
+ with the new meta queue structure; (work_queue_run) don't
+ increment the counter on work item requeueing
+
2008-02-28 Paul Jakma <paul.jakma@sun.com>
* log.c: (mes_lookup) Sowmini Varadhan diagnosed a problem where
diff --git a/lib/command.c b/lib/command.c
index f3d96ede..270bf0d3 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1,5 +1,5 @@
/*
- $Id$
+ $Id: command.c,v 1.55 2007/04/28 22:14:10 ajs Exp $
Command interpreter routine for virtual terminal [aka TeletYpe]
Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
diff --git a/lib/log.c b/lib/log.c
index ce00bfbb..df630099 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: log.c,v 1.34 2008/02/28 23:26:02 paul Exp $
*
* Logging of zebra
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
diff --git a/lib/log.h b/lib/log.h
index 7432b25e..691368c0 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: log.h,v 1.20 2008/02/28 23:26:02 paul Exp $
*
* Zebra logging funcions.
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
diff --git a/lib/md5.c b/lib/md5.c
index 887059a5..f1bd0668 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -1,6 +1,6 @@
/* $USAGI: md5.c,v 1.2 2000/11/02 11:59:24 yoshfuji Exp $ */
/* $KAME: md5.c,v 1.2 2000/05/27 07:07:48 jinmei Exp $ */
-/* $Id$ */
+/* $Id: md5.c,v 1.6 2006/01/17 23:39:04 vincent Exp $ */
/*
* Copyright (C) 2004 6WIND
diff --git a/lib/md5.h b/lib/md5.h
index 6078ac1f..89b9a320 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -1,6 +1,6 @@
/* $USAGI: md5.h,v 1.2 2000/11/02 11:59:25 yoshfuji Exp $ */
/* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */
-/* $Id$ */
+/* $Id: md5.h,v 1.3 2006/01/17 17:40:45 paul Exp $ */
/*
* Copyright (C) 2004 6WIND
diff --git a/lib/memtypes.awk b/lib/memtypes.awk
index fbd5e251..5429f6e8 100644
--- a/lib/memtypes.awk
+++ b/lib/memtypes.awk
@@ -1,4 +1,4 @@
-# $Id$
+# $Id: memtypes.awk,v 1.4 2006/03/30 14:30:19 paul Exp $
#
# Scan a file of memory definitions (see eg memtypes.c) and generate
# a corresponding header file with an enum of the MTYPE's and declarations
diff --git a/lib/memtypes.c b/lib/memtypes.c
index f1b10e71..5c2c9034 100644
--- a/lib/memtypes.c
+++ b/lib/memtypes.c
@@ -6,7 +6,7 @@
* The script is sensitive to the format (though not whitespace), see
* the top of memtypes.awk for more details.
*
- * $Id$
+ * $Id: memtypes.c,v 1.13 2008/07/21 21:02:50 paul Exp $
*/
#include "zebra.h"
@@ -95,6 +95,7 @@ struct memory_list memory_list_bgp[] =
{ MTYPE_BGP_PEER_HOST, "BGP peer hostname" },
{ MTYPE_PEER_GROUP, "Peer group" },
{ MTYPE_PEER_DESC, "Peer description" },
+ { MTYPE_PEER_PASSWORD, "Peer password string" },
{ MTYPE_ATTR, "BGP attribute" },
{ MTYPE_ATTR_EXTRA, "BGP extra attributes" },
{ MTYPE_AS_PATH, "BGP aspath" },
diff --git a/lib/route_types.awk b/lib/route_types.awk
index eb3d382a..6078406c 100644
--- a/lib/route_types.awk
+++ b/lib/route_types.awk
@@ -1,4 +1,4 @@
-# $Id$
+# $Id: route_types.awk,v 1.3 2006/06/27 10:42:18 paul Exp $
#
# Scan a file of route-type definitions (see eg route_types.txt) and
# generate a corresponding header file with:
diff --git a/lib/sockopt.c b/lib/sockopt.c
index e0027e88..2f01199a 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -22,6 +22,7 @@
#include <zebra.h>
#include "log.h"
#include "sockopt.h"
+#include "sockunion.h"
int
setsockopt_so_recvbuf (int sock, int size)
@@ -494,35 +495,69 @@ sockopt_iphdrincl_swab_systoh (struct ip *iph)
iph->ip_id = ntohs(iph->ip_id);
}
-#if defined(HAVE_TCP_MD5SIG)
int
-sockopt_tcp_signature (int sock, struct sockaddr_in *sin, const char *password)
+sockopt_tcp_signature (int sock, union sockunion *su, const char *password)
{
- int keylen = password ? strlen(password) : 0;
-
-#if defined(GNU_LINUX)
-
- struct tcp_md5sig md5sig;
-
- bzero ((char *)&md5sig, sizeof(md5sig));
- memcpy (&md5sig.tcpm_addr, sin, sizeof(*sin));
- md5sig.tcpm_keylen = keylen;
- if (keylen)
- memcpy (md5sig.tcpm_key, password, keylen);
-
- return setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof md5sig);
-
-#else /* !GNU_LINUX */
-
- int enable = keylen ? (TCP_SIG_SPI_BASE + sin->sin_port) : 0;
-
+#if HAVE_DECL_TCP_MD5SIG
+#ifndef GNU_LINUX
/*
* XXX Need to do PF_KEY operation here to add/remove an SA entry,
* and add/remove an SP entry for this peer's packet flows also.
*/
- return setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &enable,
- sizeof(enable));
-
-#endif /* !GNU_LINUX */
-}
+ int md5sig = password && *password ? 1 : 0;
+#else
+ int keylen = password ? strlen (password) : 0;
+ struct tcp_md5sig md5sig;
+ union sockunion *su2, *susock;
+ int ret;
+
+ /* Figure out whether the socket and the sockunion are the same family..
+ * adding AF_INET to AF_INET6 needs to be v4 mapped, you'd think..
+ */
+ if (!(susock = sockunion_getsockname (sock)))
+ return -1;
+
+ if (susock->sa.sa_family == su->sa.sa_family)
+ su2 = su;
+ else
+ {
+ /* oops.. */
+ su2 = susock;
+
+ if (su2->sa.sa_family == AF_INET)
+ {
+ sockunion_free (susock);
+ return -1;
+ };
+
+ /* If this does not work, then all users of this sockopt will need to
+ * differentiate between IPv4 and IPv6, and keep seperate sockets for
+ * each.
+ *
+ * Sadly, it doesn't seem to work at present. It's unknown whether
+ * this is a bug or not.
+ */
+ if (su2->sa.sa_family == AF_INET6
+ && su->sa.sa_family == AF_INET)
+ {
+ su2->sin6.sin6_family = AF_INET6;
+ /* V4Map the address */
+ memset (&su2->sin6.sin6_addr, 0, sizeof (struct in6_addr));
+ su2->sin6.sin6_addr.s6_addr32[2] = htonl(0xffff);
+ memcpy (&su2->sin6.sin6_addr.s6_addr32[3], &su->sin.sin_addr, 4);
+ }
+ }
+
+ memset (&md5sig, 0, sizeof (md5sig));
+ memcpy (&md5sig.tcpm_addr, su2, sizeof (*su2));
+ md5sig.tcpm_keylen = keylen;
+ if (keylen)
+ memcpy (md5sig.tcpm_key, password, keylen);
+#endif /* GNU_LINUX */
+ ret = setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof md5sig);
+ sockunion_free (susock);
+ return ret;
+#else /* HAVE_TCP_MD5SIG */
+ return -2;
#endif /* HAVE_TCP_MD5SIG */
+}
diff --git a/lib/sockopt.h b/lib/sockopt.h
index df0de61c..95382792 100644
--- a/lib/sockopt.h
+++ b/lib/sockopt.h
@@ -22,6 +22,8 @@
#ifndef _ZEBRA_SOCKOPT_H
#define _ZEBRA_SOCKOPT_H
+#include "sockunion.h"
+
extern int setsockopt_so_recvbuf (int sock, int size);
extern int setsockopt_so_sendbuf (const int sock, int size);
extern int getsockopt_so_sendbuf (const int sock);
@@ -87,7 +89,6 @@ extern int setsockopt_multicast_ipv4(int sock, int optname,
unsigned int ifindex
/* optional: if non-zero, may be used
instead of if_addr */);
-extern int setsockopt_ipv4_tos(int sock, int tos);
/* Ask for, and get, ifindex, by whatever method is supported. */
extern int setsockopt_ifindex (int, int, int);
@@ -99,32 +100,6 @@ extern int getsockopt_ifindex (int, struct msghdr *);
extern void sockopt_iphdrincl_swab_htosys (struct ip *iph);
extern void sockopt_iphdrincl_swab_systoh (struct ip *iph);
-#if defined(HAVE_TCP_MD5SIG)
-
-#if defined(GNU_LINUX) && !defined(TCP_MD5SIG)
-
-/* XXX these will come from <linux/tcp.h> eventually */
-
-#define TCP_MD5SIG 14
-#define TCP_MD5SIG_MAXKEYLEN 80
-
-struct tcp_md5sig {
- struct sockaddr_storage tcpm_addr; /* address associated */
- __u16 __tcpm_pad1; /* zero */
- __u16 tcpm_keylen; /* key length */
- __u32 __tcpm_pad2; /* zero */
- __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */
-};
-
-#endif /* defined(GNU_LINUX) && !defined(TCP_MD5SIG) */
-
-#if !defined(GNU_LINUX) && !defined(TCP_SIG_SPI_BASE)
-#define TCP_SIG_SPI_BASE 1000 /* XXX this will go away */
-#endif
-
-extern int sockopt_tcp_signature(int sock, struct sockaddr_in *sin,
+extern int sockopt_tcp_signature(int sock, union sockunion *su,
const char *password);
-
-#endif /* HAVE_TCP_MD5SIG */
-
#endif /*_ZEBRA_SOCKOPT_H */
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 7721666e..cfd3bf9a 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -254,6 +254,7 @@ sockunion_accept (int sock, union sockunion *su)
client_sock = accept (sock, (struct sockaddr *) su, &len);
/* Convert IPv4 compatible IPv6 address to IPv4 address. */
+#if 0
#ifdef HAVE_IPV6
if (su->sa.sa_family == AF_INET6)
{
@@ -268,7 +269,7 @@ sockunion_accept (int sock, union sockunion *su)
}
}
#endif /* HAVE_IPV6 */
-
+#endif
return client_sock;
}
@@ -592,6 +593,7 @@ sockunion_getsockname (int fd)
su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
memcpy (su, &name, sizeof (struct sockaddr_in6));
+#if 0
if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr))
{
struct sockaddr_in sin;
@@ -601,6 +603,7 @@ sockunion_getsockname (int fd)
sin.sin_port = su->sin6.sin6_port;
memcpy (su, &sin, sizeof (struct sockaddr_in));
}
+#endif
return su;
}
#endif /* HAVE_IPV6 */
@@ -645,7 +648,7 @@ sockunion_getpeername (int fd)
{
su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
memcpy (su, &name, sizeof (struct sockaddr_in6));
-
+#if 0
if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr))
{
struct sockaddr_in sin;
@@ -655,6 +658,7 @@ sockunion_getpeername (int fd)
sin.sin_port = su->sin6.sin6_port;
memcpy (su, &sin, sizeof (struct sockaddr_in));
}
+#endif
return su;
}
#endif /* HAVE_IPV6 */
diff --git a/lib/str.h b/lib/str.h
index bcee8af0..7b83fe1c 100644
--- a/lib/str.h
+++ b/lib/str.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: str.h,v 1.4 2005/09/19 09:53:21 hasso Exp $
*/
#ifndef _ZEBRA_STR_H
diff --git a/lib/stream.c b/lib/stream.c
index 7034d904..983330ff 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -458,7 +458,7 @@ stream_get_ipv4 (struct stream *s)
* stream_write() is saner
*/
void
-stream_put (struct stream *s, void *src, size_t size)
+stream_put (struct stream *s, const void *src, size_t size)
{
/* XXX: CHECK_SIZE has strange semantics. It should be deprecated */
@@ -833,7 +833,7 @@ stream_recvmsg (struct stream *s, int fd, struct msghdr *msgh, int flags,
/* Write data to buffer. */
size_t
-stream_write (struct stream *s, u_char *ptr, size_t size)
+stream_write (struct stream *s, const void *ptr, size_t size)
{
CHECK_SIZE(s, size);
diff --git a/lib/stream.h b/lib/stream.h
index 715a083d..3e4ba7b4 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -150,7 +150,7 @@ extern void stream_forward_getp (struct stream *, size_t);
extern void stream_forward_endp (struct stream *, size_t);
/* steam_put: NULL source zeroes out size_t bytes of stream */
-extern void stream_put (struct stream *, void *, size_t);
+extern void stream_put (struct stream *, const void *, size_t);
extern int stream_putc (struct stream *, u_char);
extern int stream_putc_at (struct stream *, size_t, u_char);
extern int stream_putw (struct stream *, u_int16_t);
@@ -200,7 +200,7 @@ extern ssize_t stream_recvmsg (struct stream *s, int fd, struct msghdr *,
extern ssize_t stream_recvfrom (struct stream *s, int fd, size_t len,
int flags, struct sockaddr *from,
socklen_t *fromlen);
-extern size_t stream_write (struct stream *, u_char *, size_t);
+extern size_t stream_write (struct stream *, const void *, size_t);
/* reset the stream. See Note above */
extern void stream_reset (struct stream *);
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 8880b9e2..1d32d241 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -67,7 +67,6 @@ work_queue_new (struct thread_master *m, const char *queue_name)
new->name = XSTRDUP (MTYPE_WORK_QUEUE_NAME, queue_name);
new->master = m;
SET_FLAG (new->flags, WQ_UNPLUGGED);
- UNSET_FLAG (new->flags, WQ_AIM_HEAD);
if ( (new->items = list_new ()) == NULL)
{
@@ -131,10 +130,7 @@ work_queue_add (struct work_queue *wq, void *data)
}
item->data = data;
- if (CHECK_FLAG (wq->flags, WQ_AIM_HEAD))
- listnode_add_after (wq->items, NULL, item);
- else
- listnode_add (wq->items, item);
+ listnode_add (wq->items, item);
work_queue_schedule (wq, wq->spec.hold);
@@ -231,15 +227,6 @@ work_queue_unplug (struct work_queue *wq)
work_queue_schedule (wq, wq->spec.hold);
}
-void
-work_queue_aim_head (struct work_queue *wq, const unsigned aim_head)
-{
- if (aim_head)
- SET_FLAG (wq->flags, WQ_AIM_HEAD);
- else
- UNSET_FLAG (wq->flags, WQ_AIM_HEAD);
-}
-
/* timer thread to process a work queue
* will reschedule itself if required,
* otherwise work_queue_item_add
@@ -317,6 +304,7 @@ work_queue_run (struct thread *thread)
}
case WQ_REQUEUE:
{
+ item->ran--;
work_queue_item_requeue (wq, node);
break;
}
diff --git a/lib/workqueue.h b/lib/workqueue.h
index 3150c32e..f59499a0 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -48,7 +48,6 @@ struct work_queue_item
};
#define WQ_UNPLUGGED (1 << 0) /* available for draining */
-#define WQ_AIM_HEAD (1 << 1) /* add new items before list head, not after tail */
struct work_queue
{
@@ -119,8 +118,6 @@ extern void work_queue_add (struct work_queue *, void *);
extern void work_queue_plug (struct work_queue *wq);
/* unplug the queue, allow it to be drained again */
extern void work_queue_unplug (struct work_queue *wq);
-/* control the value for WQ_AIM_HEAD flag */
-extern void work_queue_aim_head (struct work_queue *wq, const unsigned);
/* Helpers, exported for thread.c and command.c */
extern int work_queue_run (struct thread *);
diff --git a/lib/zassert.h b/lib/zassert.h
index 525d866c..79126760 100644
--- a/lib/zassert.h
+++ b/lib/zassert.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $
*/
#ifndef _QUAGGA_ASSERT_H
diff --git a/lib/zebra.h b/lib/zebra.h
index d4f68cf0..2716460f 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -163,6 +163,7 @@ typedef int socklen_t;
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/filter.h>
+#include <stddef.h>
#else
#define RT_TABLE_MAIN 0
#endif /* HAVE_NETLINK */