Pull up following revision(s) (requested by riastradh in ticket #1881):
usr.sbin/ldpd/socketops.c: revision 1.36 usr.sbin/ldpd/fsm.c: revision 1.16 usr.sbin/ldpd/ldp_peer.c: revision 1.19 ldpd(8): Fix address of misaligned packed members. PR kern/56895
This commit is contained in:
parent
fb6c0c031a
commit
1dec367e03
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fsm.c,v 1.15 2014/03/18 18:20:47 riastradh Exp $ */
|
||||
/* $NetBSD: fsm.c,v 1.15.18.1 2023/08/04 13:28:40 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
|
@ -59,6 +59,7 @@ run_ldp_hello(const struct ldp_pdu * pduid, const struct hello_tlv * ht,
|
|||
const struct transport_address_tlv *trtlv;
|
||||
struct hello_info *hi = NULL;
|
||||
union sockunion traddr;
|
||||
struct in_addr ldp_id;
|
||||
|
||||
if ((!pduid) || (!ht))
|
||||
return;
|
||||
|
@ -125,7 +126,8 @@ run_ldp_hello(const struct ldp_pdu * pduid, const struct hello_tlv * ht,
|
|||
hi->keepalive = LDP_THELLO_KEEP;
|
||||
}
|
||||
|
||||
if (!get_ldp_peer_by_id(&pduid->ldp_id)) {
|
||||
ldp_id = pduid->ldp_id;
|
||||
if (!get_ldp_peer_by_id(&ldp_id)) {
|
||||
/*
|
||||
* RFC 5036 2.5.2: If A1 > A2, LSR1 plays the active role;
|
||||
* otherwise it is passive.
|
||||
|
@ -134,7 +136,7 @@ run_ldp_hello(const struct ldp_pdu * pduid, const struct hello_tlv * ht,
|
|||
(hi->transport_address.sa.sa_family == AF_INET &&
|
||||
ntohl(hi->transport_address.sin.sin_addr.s_addr) <
|
||||
ntohl(ladd->s_addr))) {
|
||||
peer = ldp_peer_new(&pduid->ldp_id, padd,
|
||||
peer = ldp_peer_new(&ldp_id, padd,
|
||||
&hi->transport_address.sa,
|
||||
ntohs(ht->ch.holdtime), 0);
|
||||
if (peer == NULL)
|
||||
|
@ -151,7 +153,7 @@ build_address_list_tlv(void)
|
|||
struct address_list_tlv *t;
|
||||
struct ifaddrs *ifa, *ifb;
|
||||
struct sockaddr_in *sa;
|
||||
struct in_addr *ia;
|
||||
char *ia;
|
||||
uint16_t adrcount = 0;
|
||||
|
||||
if (getifaddrs(&ifa) == -1)
|
||||
|
@ -184,7 +186,7 @@ build_address_list_tlv(void)
|
|||
adrcount * sizeof(struct in_addr));
|
||||
t->a_af = htons(LDP_AF_INET);
|
||||
|
||||
ia = &t->a_address;
|
||||
ia = (void *)&t->a_address;
|
||||
for (adrcount = 0, ifb = ifa; ifb; ifb = ifb->ifa_next) {
|
||||
if ((ifb->ifa_addr->sa_family != AF_INET) ||
|
||||
(!(ifb->ifa_flags & IFF_UP)))
|
||||
|
@ -192,7 +194,8 @@ build_address_list_tlv(void)
|
|||
sa = (struct sockaddr_in *) ifb->ifa_addr;
|
||||
if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
|
||||
continue;
|
||||
memcpy(&ia[adrcount], &sa->sin_addr, sizeof(struct in_addr));
|
||||
memcpy(ia + adrcount*sizeof(struct in_addr), &sa->sin_addr,
|
||||
sizeof(struct in_addr));
|
||||
adrcount++;
|
||||
}
|
||||
freeifaddrs(ifa);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ldp_peer.c,v 1.16 2013/08/02 07:29:56 kefren Exp $ */
|
||||
/* $NetBSD: ldp_peer.c,v 1.16.18.1 2023/08/04 13:28:40 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
|
@ -306,7 +306,7 @@ int
|
|||
add_ifaddresses(struct ldp_peer * p, const struct al_tlv * a)
|
||||
{
|
||||
int i, c, n;
|
||||
const struct in_addr *ia;
|
||||
const char *ia;
|
||||
struct sockaddr_in ipa;
|
||||
|
||||
memset(&ipa, 0, sizeof(ipa));
|
||||
|
@ -328,8 +328,9 @@ add_ifaddresses(struct ldp_peer * p, const struct al_tlv * a)
|
|||
debugp("Trying to add %d addresses to peer %s ... \n", n,
|
||||
inet_ntoa(p->ldp_id));
|
||||
|
||||
for (ia = (const struct in_addr *) & a->address,c = 0,i = 0; i<n; i++) {
|
||||
memcpy(&ipa.sin_addr, &ia[i], sizeof(ipa.sin_addr));
|
||||
for (ia = (const void *)&a->address, c = 0, i = 0; i < n; i++) {
|
||||
memcpy(&ipa.sin_addr, ia + i*sizeof(ipa.sin_addr),
|
||||
sizeof(ipa.sin_addr));
|
||||
if (add_ifaddr(p, (struct sockaddr *)&ipa) == LDP_E_OK)
|
||||
c++;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: socketops.c,v 1.34 2017/04/12 17:02:51 roy Exp $ */
|
||||
/* $NetBSD: socketops.c,v 1.34.4.1 2023/08/04 13:28:40 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
|
@ -401,6 +401,7 @@ send_hello(void)
|
|||
struct hello_tlv *t;
|
||||
struct common_hello_tlv *cht;
|
||||
struct ldp_pdu *spdu;
|
||||
struct in_addr ldp_id;
|
||||
struct transport_address_tlv *trtlv;
|
||||
void *v;
|
||||
struct sockaddr_in sadest; /* Destination ALL_ROUTERS */
|
||||
|
@ -440,7 +441,8 @@ send_hello(void)
|
|||
/* Prepare PDU envelope */
|
||||
spdu->version = htons(LDP_VERSION);
|
||||
spdu->length = htons(IPV4_HELLO_MSG_SIZE - PDU_VER_LENGTH);
|
||||
inet_aton(LDP_ID, &spdu->ldp_id);
|
||||
inet_aton(LDP_ID, &ldp_id);
|
||||
spdu->ldp_id = ldp_id;
|
||||
|
||||
/* Prepare Hello TLV */
|
||||
t->type = htons(LDP_HELLO);
|
||||
|
@ -1384,10 +1386,13 @@ send_message(const struct ldp_peer * p, const struct ldp_pdu * pdu,
|
|||
int
|
||||
send_tlv(const struct ldp_peer * p, const struct tlv * t)
|
||||
{
|
||||
struct in_addr ldp_id;
|
||||
struct ldp_pdu pdu;
|
||||
|
||||
inet_aton(LDP_ID, &ldp_id);
|
||||
|
||||
pdu.version = htons(LDP_VERSION);
|
||||
inet_aton(LDP_ID, &pdu.ldp_id);
|
||||
pdu.ldp_id = ldp_id;
|
||||
pdu.label_space = 0;
|
||||
pdu.length = htons(ntohs(t->length) + TLV_TYPE_LENGTH +
|
||||
PDU_PAYLOAD_LENGTH);
|
||||
|
|
Loading…
Reference in New Issue