mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 07:37:29 +00:00
ospfd: fix vrf bind sock non-linux system
For non GNU_LINUX like open Bsd avoid sending packet to non vrf aware device using in_pktinfo. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
parent
e7503eab31
commit
e1b18df1ea
@ -153,6 +153,18 @@ int ospf_if_ipmulticast(struct ospf *top, struct prefix *p, ifindex_t ifindex)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
zlog_warn("can't setsockopt IP_MULTICAST_TTL(1) for fd %d: %s",
|
zlog_warn("can't setsockopt IP_MULTICAST_TTL(1) for fd %d: %s",
|
||||||
top->fd, safe_strerror(errno));
|
top->fd, safe_strerror(errno));
|
||||||
|
#ifndef GNU_LINUX
|
||||||
|
/* For GNU LINUX ospf_write uses IP_PKTINFO, in_pktinfo to send
|
||||||
|
* packet out of ifindex. Below would be used Non Linux system.
|
||||||
|
*/
|
||||||
|
ret = setsockopt_ipv4_multicast_if(top->fd, p->u.prefix4, ifindex);
|
||||||
|
if (ret < 0)
|
||||||
|
zlog_warn(
|
||||||
|
"can't setsockopt IP_MULTICAST_IF(fd %d, addr %s, "
|
||||||
|
"ifindex %u): %s",
|
||||||
|
top->fd, inet_ntoa(p->u.prefix4), ifindex,
|
||||||
|
safe_strerror(errno));
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -648,9 +648,12 @@ static int ospf_write(struct thread *thread)
|
|||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
#define OSPF_WRITE_IPHL_SHIFT 2
|
#define OSPF_WRITE_IPHL_SHIFT 2
|
||||||
int pkt_count = 0;
|
int pkt_count = 0;
|
||||||
|
|
||||||
|
#ifdef GNU_LINUX
|
||||||
unsigned char cmsgbuf[64] = {};
|
unsigned char cmsgbuf[64] = {};
|
||||||
struct cmsghdr *cm = (struct cmsghdr *)cmsgbuf;
|
struct cmsghdr *cm = (struct cmsghdr *)cmsgbuf;
|
||||||
struct in_pktinfo *pi;
|
struct in_pktinfo *pi;
|
||||||
|
#endif
|
||||||
|
|
||||||
ospf->t_write = NULL;
|
ospf->t_write = NULL;
|
||||||
|
|
||||||
@ -756,13 +759,14 @@ static int ospf_write(struct thread *thread)
|
|||||||
msg.msg_namelen = sizeof(sa_dst);
|
msg.msg_namelen = sizeof(sa_dst);
|
||||||
msg.msg_iov = iov;
|
msg.msg_iov = iov;
|
||||||
msg.msg_iovlen = 2;
|
msg.msg_iovlen = 2;
|
||||||
msg.msg_control = (caddr_t)cm;
|
|
||||||
|
|
||||||
iov[0].iov_base = (char *)&iph;
|
iov[0].iov_base = (char *)&iph;
|
||||||
iov[0].iov_len = iph.ip_hl << OSPF_WRITE_IPHL_SHIFT;
|
iov[0].iov_len = iph.ip_hl << OSPF_WRITE_IPHL_SHIFT;
|
||||||
iov[1].iov_base = STREAM_PNT(op->s);
|
iov[1].iov_base = STREAM_PNT(op->s);
|
||||||
iov[1].iov_len = op->length;
|
iov[1].iov_len = op->length;
|
||||||
|
|
||||||
|
#ifdef GNU_LINUX
|
||||||
|
msg.msg_control = (caddr_t)cm;
|
||||||
cm->cmsg_level = SOL_IP;
|
cm->cmsg_level = SOL_IP;
|
||||||
cm->cmsg_type = IP_PKTINFO;
|
cm->cmsg_type = IP_PKTINFO;
|
||||||
cm->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
|
cm->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
|
||||||
@ -770,7 +774,7 @@ static int ospf_write(struct thread *thread)
|
|||||||
pi->ipi_ifindex = oi->ifp->ifindex;
|
pi->ipi_ifindex = oi->ifp->ifindex;
|
||||||
|
|
||||||
msg.msg_controllen = cm->cmsg_len;
|
msg.msg_controllen = cm->cmsg_len;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Sadly we can not rely on kernels to fragment packets
|
/* Sadly we can not rely on kernels to fragment packets
|
||||||
* because of either IP_HDRINCL and/or multicast
|
* because of either IP_HDRINCL and/or multicast
|
||||||
|
Loading…
Reference in New Issue
Block a user