Hi --

I'm submitting this patch for another engineer on my team, thus his name in the "signed off-by" field.

We ran into an issue where if an interface had multiple IP addresses, the PTP multicast traffic would be sourced randomly which broke our PTP implementation.

I'll field any questions on this patch.

Best regards.

Bob Carter

-----------
On a host with multiple subnets per interface we want PTP multicast
traffic to be always sourced from the first subnet on the interface,
not one randomly chosen.

Signed-off-by: Michael Haley <mike.ha...@octoscope.com>
---
 udp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/udp.c b/udp.c
index 48af482..287946f 100644
--- a/udp.c
+++ b/udp.c
@@ -48,11 +48,14 @@ struct udp {
        struct address mac;
 };

-static int mcast_bind(int fd, int index)
+static int mcast_bind(int fd, const char *name, int index)
 {
        int err;
+       struct address a;
        struct ip_mreqn req;
        memset(&req, 0, sizeof(req));
+       sk_interface_addr(name, AF_INET, &a);
+       (req.imr_address) = (a.sin.sin_addr);
        req.imr_ifindex = index;
err = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, &req, sizeof(req));
        if (err) {
@@ -136,7 +139,7 @@ static int open_socket(const char *name, struct in_addr mc_addr[2], short port,
                pr_err("mcast_join failed");
                goto no_option;
        }
-       if (mcast_bind(fd, index)) {
+       if (mcast_bind(fd, name, index)) {
                goto no_option;
        }
        return fd;
--
2.17.1


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to