mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 03:53:38 +00:00
Rationalize CMSG_SPACE usage:
in lib/zebra.h, ensure that RFC3542-required CMSG_SPACE and CMSG_LEN are defined. Warn if alignment assumptions are made, since they are i386-centric. in lib/sockopt.h, declare that sockopt sizes are without CMSG_SPACE-required padding - just simple sizeof. in ospfd/ospf_packet.c, simply use CMSG_SPACE This should remove all instances of CMSG_ALIGN from the source code. This is a nonstandard, though rational, construct; quagga should use only those defines in RFC3542.
This commit is contained in:
parent
fbb6709986
commit
69e1325faf
@ -1,3 +1,11 @@
|
|||||||
|
2004-11-15 Greg Troxel <gdt@fnord.ir.bbn.com>
|
||||||
|
|
||||||
|
* sockopt.h: Avoid CMSG_ALIGN, and declare that sizes are without
|
||||||
|
alignment (users should use CMSG_SPACE).
|
||||||
|
|
||||||
|
* zebra.h: Rationalize CMSG_SPACE compatibility defines. Warn if
|
||||||
|
asumming 4-byte alignment, since this isn't safe.
|
||||||
|
|
||||||
2004-11-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
2004-11-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
||||||
|
|
||||||
* memory.c: (zerror) Use zlog_err instead of fprintf to stderr.
|
* memory.c: (zerror) Use zlog_err instead of fprintf to stderr.
|
||||||
|
@ -44,7 +44,7 @@ int setsockopt_ipv6_multicast_loop (int, int);
|
|||||||
* Size defines for control messages used to get ifindex. We define
|
* Size defines for control messages used to get ifindex. We define
|
||||||
* values for each method, and define a macro that can be used by code
|
* values for each method, and define a macro that can be used by code
|
||||||
* that is unaware of which method is in use.
|
* that is unaware of which method is in use.
|
||||||
* XXX Needs to use CMSG_DATA and CMSG_ALIGN.
|
* These values are without any alignment needed (see CMSG_SPACE in RFC3542).
|
||||||
*/
|
*/
|
||||||
#if defined (IP_PKTINFO)
|
#if defined (IP_PKTINFO)
|
||||||
/* Linux in_pktinfo. */
|
/* Linux in_pktinfo. */
|
||||||
@ -61,8 +61,7 @@ int setsockopt_ipv6_multicast_loop (int, int);
|
|||||||
#if defined (SUNOS_5)
|
#if defined (SUNOS_5)
|
||||||
#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof (uint_t))
|
#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof (uint_t))
|
||||||
#else
|
#else
|
||||||
#define SOPT_SIZE_CMSG_RECVIF_IPV4() \
|
#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof (struct sockaddr_dl))
|
||||||
__CMSG_ALIGN((sizeof (struct sockaddr_dl)))
|
|
||||||
#endif /* SUNOS_5 */
|
#endif /* SUNOS_5 */
|
||||||
#endif /* IP_RECVIF */
|
#endif /* IP_RECVIF */
|
||||||
|
|
||||||
|
16
lib/zebra.h
16
lib/zebra.h
@ -210,7 +210,13 @@ typedef int socklen_t;
|
|||||||
#endif /* BSDI_NRL */
|
#endif /* BSDI_NRL */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RFC 2553-bis defines not available on some systems.
|
* RFC 3542 defines several macros for using struct cmsghdr.
|
||||||
|
* Here, we define those that are not present
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal defines, for use only in this file.
|
||||||
|
* These are likely wrong on other than ILP32 machines, so warn.
|
||||||
*/
|
*/
|
||||||
#ifndef _CMSG_DATA_ALIGN
|
#ifndef _CMSG_DATA_ALIGN
|
||||||
#define _CMSG_DATA_ALIGN(n) (((n) + 3) & ~3)
|
#define _CMSG_DATA_ALIGN(n) (((n) + 3) & ~3)
|
||||||
@ -220,16 +226,24 @@ typedef int socklen_t;
|
|||||||
#define _CMSG_HDR_ALIGN(n) (((n) + 3) & ~3)
|
#define _CMSG_HDR_ALIGN(n) (((n) + 3) & ~3)
|
||||||
#endif /* _CMSG_HDR_ALIGN */
|
#endif /* _CMSG_HDR_ALIGN */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CMSG_SPACE and CMSG_LEN are required in RFC3542, but were new in that
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
#ifndef CMSG_SPACE
|
#ifndef CMSG_SPACE
|
||||||
#define CMSG_SPACE(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + \
|
#define CMSG_SPACE(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + \
|
||||||
_CMSG_HDR_ALIGN(l))
|
_CMSG_HDR_ALIGN(l))
|
||||||
|
#warning "assuming 4-byte alignment for CMSG_SPACE"
|
||||||
#endif /* CMSG_SPACE */
|
#endif /* CMSG_SPACE */
|
||||||
|
|
||||||
|
|
||||||
#ifndef CMSG_LEN
|
#ifndef CMSG_LEN
|
||||||
#define CMSG_LEN(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + (l))
|
#define CMSG_LEN(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + (l))
|
||||||
|
#warning "assuming 4-byte alignment for CMSG_LEN"
|
||||||
#endif /* CMSG_LEN */
|
#endif /* CMSG_LEN */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !(defined(__GNUC__) || defined(VTYSH_EXTRACT_PL))
|
#if !(defined(__GNUC__) || defined(VTYSH_EXTRACT_PL))
|
||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
#endif /* !__GNUC__ */
|
#endif /* !__GNUC__ */
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2004-11-15 Greg Troxel <gdt@fnord.ir.bbn.com>
|
||||||
|
|
||||||
|
* ospf_packet.c (ospf_recv_packet): Assume CMSG_SPACE is present
|
||||||
|
and works (lib/zebra.h provides if OS doesn't).
|
||||||
|
|
||||||
2004-11-15 Paul Jakma <paul@dishone.st>
|
2004-11-15 Paul Jakma <paul@dishone.st>
|
||||||
|
|
||||||
* ospf_{apiserver,te}.c: ospf_lsa_free's should be ospf_lsa_unlock.
|
* ospf_{apiserver,te}.c: ospf_lsa_free's should be ospf_lsa_unlock.
|
||||||
|
@ -2007,12 +2007,8 @@ ospf_recv_packet (int fd, struct interface **ifp)
|
|||||||
struct stream *ibuf;
|
struct stream *ibuf;
|
||||||
unsigned int ifindex = 0;
|
unsigned int ifindex = 0;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
#if defined(CMSG_SPACE)
|
|
||||||
/* Header and data both require alignment. */
|
/* Header and data both require alignment. */
|
||||||
char buff [CMSG_SPACE(SOPT_SIZE_CMSG_IFINDEX_IPV4())];
|
char buff [CMSG_SPACE(SOPT_SIZE_CMSG_IFINDEX_IPV4())];
|
||||||
#else
|
|
||||||
char buff [sizeof (struct cmsghdr) + SOPT_SIZE_CMSG_IFINDEX_IPV4()];
|
|
||||||
#endif
|
|
||||||
struct msghdr msgh;
|
struct msghdr msgh;
|
||||||
|
|
||||||
memset (&msgh, 0, sizeof (struct msghdr));
|
memset (&msgh, 0, sizeof (struct msghdr));
|
||||||
|
Loading…
Reference in New Issue
Block a user