From fa31fcf2ea1157d3d14968d704878cc8fe058c91 Mon Sep 17 00:00:00 2001 From: Amol Lad Date: Wed, 17 Feb 2021 13:47:32 +1300 Subject: nhrpd: Add support for forwarding multicast packets Forwarding multicast is a pre-requisite for allowing multicast based routing protocols such as OSPF to work with DMVPN This code relies on externally adding iptables rule. For example: iptables -A OUTPUT -d 224.0.0.0/24 -o gre1 -j NFLOG --nflog-group 224 Signed-off-by: Reuben Dowle --- nhrpd/linux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'nhrpd/linux.c') diff --git a/nhrpd/linux.c b/nhrpd/linux.c index 59c82b1c5..20825149b 100644 --- a/nhrpd/linux.c +++ b/nhrpd/linux.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,7 @@ int os_socket(void) } int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr, - size_t addrlen) + size_t addrlen, uint16_t protocol) { struct sockaddr_ll lladdr; struct iovec iov = { @@ -61,16 +62,16 @@ int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr, memset(&lladdr, 0, sizeof(lladdr)); lladdr.sll_family = AF_PACKET; - lladdr.sll_protocol = htons(ETH_P_NHRP); + lladdr.sll_protocol = htons(protocol); lladdr.sll_ifindex = ifindex; lladdr.sll_halen = addrlen; memcpy(lladdr.sll_addr, addr, addrlen); - status = sendmsg(nhrp_socket_fd, &msg, 0); + status = sendmsg(os_socket(), &msg, 0); if (status < 0) - return -1; + return -errno; - return 0; + return status; } int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, -- cgit v1.2.3