mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 03:27:25 +00:00
pim6d: IPv6 headers are always stripped on receive
IPV6_HDRINCL is a TX-only option (unlike IP_HDRINCL), so on RX there never are IPv6 headers to be looked at / skipped over. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
f20d0d7cf2
commit
5e6e8a3959
@ -149,10 +149,13 @@ static bool pim_pkt_dst_addr_ok(enum pim_msg_type type, pim_addr addr)
|
||||
return true;
|
||||
}
|
||||
|
||||
int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
|
||||
int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len,
|
||||
pim_sgaddr sg)
|
||||
{
|
||||
#if PIM_IPV == 4
|
||||
struct ip *ip_hdr = (struct ip *)buf;
|
||||
size_t ip_hlen; /* ip header length in bytes */
|
||||
#endif
|
||||
uint8_t *pim_msg;
|
||||
uint32_t pim_msg_len = 0;
|
||||
uint16_t pim_checksum; /* received checksum */
|
||||
@ -160,8 +163,8 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
|
||||
struct pim_neighbor *neigh;
|
||||
struct pim_msg_header *header;
|
||||
bool no_fwd;
|
||||
pim_sgaddr sg;
|
||||
|
||||
#if PIM_IPV == 4
|
||||
if (len < sizeof(*ip_hdr)) {
|
||||
if (PIM_DEBUG_PIM_PACKETS)
|
||||
zlog_debug(
|
||||
@ -171,10 +174,15 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
|
||||
}
|
||||
|
||||
ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
|
||||
sg = pim_sgaddr_from_iphdr(buf);
|
||||
sg = pim_sgaddr_from_iphdr(ip_hdr);
|
||||
|
||||
pim_msg = buf + ip_hlen;
|
||||
pim_msg_len = len - ip_hlen;
|
||||
#else
|
||||
/* NB: header is not included in IPv6 RX */
|
||||
pim_msg = buf;
|
||||
pim_msg_len = len;
|
||||
#endif
|
||||
|
||||
header = (struct pim_msg_header *)pim_msg;
|
||||
if (pim_msg_len < PIM_PIM_MIN_LEN) {
|
||||
@ -332,6 +340,8 @@ static void pim_sock_read(struct thread *t)
|
||||
pim_ifp = ifp->info;
|
||||
|
||||
while (cont) {
|
||||
pim_sgaddr sg;
|
||||
|
||||
len = pim_socket_recvfromto(fd, buf, sizeof(buf), &from,
|
||||
&fromlen, &to, &tolen, &ifindex);
|
||||
if (len < 0) {
|
||||
@ -361,7 +371,15 @@ static void pim_sock_read(struct thread *t)
|
||||
ifindex);
|
||||
goto done;
|
||||
}
|
||||
int fail = pim_pim_packet(ifp, buf, len);
|
||||
#if PIM_IPV == 4
|
||||
sg.src = ((struct sockaddr_in *)&from)->sin_addr;
|
||||
sg.grp = ((struct sockaddr_in *)&to)->sin_addr;
|
||||
#else
|
||||
sg.src = ((struct sockaddr_in6 *)&from)->sin6_addr;
|
||||
sg.grp = ((struct sockaddr_in6 *)&to)->sin6_addr;
|
||||
#endif
|
||||
|
||||
int fail = pim_pim_packet(ifp, buf, len, sg);
|
||||
if (fail) {
|
||||
if (PIM_DEBUG_PIM_PACKETS)
|
||||
zlog_debug("%s: pim_pim_packet() return=%d",
|
||||
|
@ -54,7 +54,8 @@ void pim_sock_delete(struct interface *ifp, const char *delete_message);
|
||||
void pim_hello_restart_now(struct interface *ifp);
|
||||
void pim_hello_restart_triggered(struct interface *ifp);
|
||||
|
||||
int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len);
|
||||
int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len,
|
||||
pim_sgaddr sg);
|
||||
|
||||
int pim_msg_send(int fd, pim_addr src, pim_addr dst, uint8_t *pim_msg,
|
||||
int pim_msg_size, const char *ifname);
|
||||
|
Loading…
Reference in New Issue
Block a user