From 5a54df971e7da8aacddbf54afa33bd81b6c01f13 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 21 Feb 2006 01:37:14 +0000 Subject: [lib/sockunion] trivial: use XSTRDUP. 2006-02-21 Paul Jakma * sockunion.c: (sockunion_{su2str,log}) Use XSTRDUP. Particularly with _su2str, as that string gets XFREEd, which can be annoying if run debug code in memory.c. --- lib/sockunion.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sockunion.c') diff --git a/lib/sockunion.c b/lib/sockunion.c index e79f034c..109f3bdd 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -224,7 +224,7 @@ sockunion_su2str (union sockunion *su) break; #endif /* HAVE_IPV6 */ } - return strdup (str); + return XSTRDUP (MTYPE_TMP, str); } /* Return socket of sockunion. */ @@ -314,7 +314,7 @@ sockunion_log (union sockunion *su) snprintf (buf, SU_ADDRSTRLEN, "af_unknown %d ", su->sa.sa_family); break; } - return (strdup (buf)); + return (XSTRDUP (MTYPE_TMP, buf)); } /* sockunion_connect returns -- cgit v1.2.3 From 6f0e3f6e17687eb25b7b77c4fdc8324837d4700f Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 10 May 2007 02:38:51 +0000 Subject: [autoconf] bugs 162,303,178: Fix 'present but can not be compiled' warnings 2007-05-09 Paul Jakma * configure.ac: sys/conf.h depends on sys/param.h, at least on FBSD 6.2. (bug #363) Should check for in_pktinfo for IRDP 2006-05-27 Paul Jakma * configure.ac: General cleanup of header and type checks, introducing an internal define, QUAGGA_INCLUDES, to build up a list of stuff to include so as to avoid 'present but cant be compiled' warnings. Misc additional checks of things missing according to autoscan. Add LIBM, for bgpd's use of libm, so as to avoid burdening LIBS, and all the binaries, with libm linkage. Remove the bad practice of using m4 changequote(), just quote the []'s in the case statements properly. This should fix bugs 162, 303 and 178. * */*.{c,h}: Update all HAVE_* to the standard autoconf namespaced HAVE_* defines. I.e. HAVE_SA_LEN -> HAVE_STRUCT_SOCKADDR_SA_LEN, * bgpd/Makefile.am: Add LIBM to bgpd's LDADD, for pow(). --- lib/sockunion.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/sockunion.c') diff --git a/lib/sockunion.c b/lib/sockunion.c index 109f3bdd..7721666e 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -143,9 +143,9 @@ str2sockunion (const char *str, union sockunion *su) if (ret > 0) /* Valid IPv4 address format. */ { su->sin.sin_family = AF_INET; -#ifdef HAVE_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN su->sin.sin_len = sizeof(struct sockaddr_in); -#endif /* HAVE_SIN_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ return 0; } #ifdef HAVE_IPV6 @@ -187,9 +187,9 @@ sockunion_str2su (const char *str) if (ret > 0) /* Valid IPv4 address format. */ { su->sin.sin_family = AF_INET; -#ifdef HAVE_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN su->sin.sin_len = sizeof(struct sockaddr_in); -#endif /* HAVE_SIN_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ return su; } #ifdef HAVE_IPV6 @@ -342,12 +342,12 @@ sockunion_connect (int fd, union sockunion *peersu, unsigned short port, #ifdef KAME if (IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr) && ifindex) { -#ifdef HAVE_SIN6_SCOPE_ID +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID /* su.sin6.sin6_scope_id = ifindex; */ #ifdef MUSICA su.sin6.sin6_scope_id = ifindex; #endif -#endif /* HAVE_SIN6_SCOPE_ID */ +#endif /* HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID */ #ifndef MUSICA SET_IN6_LINKLOCAL_IFINDEX (su.sin6.sin6_addr, ifindex); #endif @@ -416,9 +416,9 @@ sockunion_bind (int sock, union sockunion *su, unsigned short port, { size = sizeof (struct sockaddr_in); su->sin.sin_port = htons (port); -#ifdef HAVE_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN su->sin.sin_len = size; -#endif /* HAVE_SIN_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ if (su_addr == NULL) su->sin.sin_addr.s_addr = htonl (INADDR_ANY); } -- cgit v1.2.3 From 0df7c91f048f2116610d6bdfce3ab6cad1981802 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Mon, 21 Jul 2008 21:02:49 +0000 Subject: [bgpd] TCP-MD5: password vty configuration and initial Linux support 2008-07-21 Paul Jakma * bgp_packet.c: (bgp_open_receive) fix warning in a zlog call * bgp_vty.c: (bgp_vty_return) add return code * bgpd.c: (bgp_master_init) setup the socket list. * bgp_network.c: Remove the dual IPv4/6 socket thing for now, which was implemented by Michael, until such time as its clear its required for Linux (see sockopt comments). IPv6 support, including IPv4 sessions on AF_INET6 sockets, therefore is broken, and the '-l 0.0.0.0' arguments would need to be given to bgpd to make things work here. 2008-07-21 Michael H. Warfield YOSHIFUJI Hideaki Tomohiko Kusuda Leigh Brown * bgp_network.c: (bgp_md5_set_one) shim between libzebra tcp-md5 sockopt and bgpd. (bgp_md5_set_socket) Helper for bgp_connect (bgp_md5_set) setup TCP-MD5SIG for the given peer. (bgp_connect) call out to bgp_md5_set_socket for the outgoing connect socket. (bgp_socket) save references to the listen sockets, needed if TCP-MD5SIG is applied later or changed. * bgp_vty.c: (*neighbor_password_cmd) New 'neighbor ... password' commands. * bgpd.c: (peer_{new,delete) manage TCP-MD5 password (peer_group2peer_config_copy) inherit TCP-MD5 password (peer_password_{un,}set) orchestrate the whole add/remove of TCP-MD5 passwords: applying checks, stopping peers, and trying to return errors to UI, etc. (bgp_config_write_peer) save password. Fix missing newline in writeout of neighbor ... port. 2008-07-21 Paul Jakma * 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 YOSHIFUJI Hideaki * sockopt.{c,h}: (sockopt_tcp_signature) Add TCP-MD5SIG support. --- lib/sockunion.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/sockunion.c') 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 */ -- cgit v1.2.3 From 1a7dcf42a244d758732464be389f5cdb1358b9e4 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 9 Sep 2008 21:17:04 +0100 Subject: [lib] re-enable conversion of v6mapped INET6 sockunions to regular INET * lib/sockunion.c: Re-enable conversion of v6mapped INET6 sockunions to regular INET sockunions, which was disabled in 0df7c9, as it leads to failures in sockunion_cmp. (sockunion_normalise_mapped) consolidate here (sockunion_accept) remove conversion code altogether here - no sockunion is created (sockunion_get{sockname,peername}) normalise newly created sockunion. --- lib/sockunion.c | 60 +++++++++++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) (limited to 'lib/sockunion.c') diff --git a/lib/sockunion.c b/lib/sockunion.c index cfd3bf9a..8fbe3450 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -227,6 +227,24 @@ sockunion_su2str (union sockunion *su) return XSTRDUP (MTYPE_TMP, str); } +/* Convert IPv4 compatible IPv6 address to IPv4 address. */ +static void +sockunion_normalise_mapped (union sockunion *su) +{ + struct sockaddr_in sin; + +#ifdef HAVE_IPV6 + if (su->sa.sa_family == AF_INET6 + && IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) + { + memset (&sin, 0, sizeof (struct sockaddr_in)); + sin.sin_family = AF_INET; + memcpy (&sin.sin_addr, ((char *)&su->sin6.sin6_addr) + 12, 4); + memcpy (su, &sin, sizeof (struct sockaddr_in)); + } +#endif /* HAVE_IPV6 */ +} + /* Return socket of sockunion. */ int sockunion_socket (union sockunion *su) @@ -253,23 +271,6 @@ sockunion_accept (int sock, union sockunion *su) len = sizeof (union sockunion); 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) - { - if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) - { - struct sockaddr_in sin; - - memset (&sin, 0, sizeof (struct sockaddr_in)); - sin.sin_family = AF_INET; - memcpy (&sin.sin_addr, ((char *)&su->sin6.sin6_addr) + 12, 4); - memcpy (su, &sin, sizeof (struct sockaddr_in)); - } - } -#endif /* HAVE_IPV6 */ -#endif return client_sock; } @@ -592,18 +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; - - sin.sin_family = AF_INET; - memcpy (&sin.sin_addr, ((char *)&su->sin6.sin6_addr) + 12, 4); - sin.sin_port = su->sin6.sin6_port; - memcpy (su, &sin, sizeof (struct sockaddr_in)); - } -#endif + sockunion_normalise_mapped (su); return su; } #endif /* HAVE_IPV6 */ @@ -648,17 +638,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; - - sin.sin_family = AF_INET; - memcpy (&sin.sin_addr, ((char *)&su->sin6.sin6_addr) + 12, 4); - sin.sin_port = su->sin6.sin6_port; - memcpy (su, &sin, sizeof (struct sockaddr_in)); - } -#endif + sockunion_normalise_mapped (su); return su; } #endif /* HAVE_IPV6 */ -- cgit v1.2.3