]> git.proxmox.com Git - mirror_frr.git/blobdiff - eigrpd/eigrp_network.c
pimd: All paths have already derefed pim->global_scope.bsrp_table
[mirror_frr.git] / eigrpd / eigrp_network.c
index 76f8cfc93b9f3224112b598ae1553d8e7db2cb80..3e09ec41bbc8c3e7e86207ab5a68505c73cf0e75 100644 (file)
@@ -53,16 +53,21 @@ static int eigrp_network_match_iface(const struct prefix *connected_prefix,
 static void eigrp_network_run_interface(struct eigrp *, struct prefix *,
                                        struct interface *);
 
-int eigrp_sock_init(void)
+int eigrp_sock_init(struct vrf *vrf)
 {
-       int eigrp_sock;
+       int eigrp_sock = -1;
        int ret;
 #ifdef IP_HDRINCL
        int hincl = 1;
 #endif
 
-       frr_elevate_privs(&eigrpd_privs) {
-               eigrp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_EIGRPIGP);
+       if (!vrf)
+               return eigrp_sock;
+
+       frr_with_privs(&eigrpd_privs) {
+               eigrp_sock = vrf_socket(
+                       AF_INET, SOCK_RAW, IPPROTO_EIGRPIGP, vrf->vrf_id,
+                       vrf->vrf_id != VRF_DEFAULT ? vrf->name : NULL);
                if (eigrp_sock < 0) {
                        zlog_err("eigrp_read_sock_init: socket: %s",
                                 safe_strerror(errno));
@@ -108,7 +113,6 @@ void eigrp_adjust_sndbuflen(struct eigrp *eigrp, unsigned int buflen)
        /* Check if any work has to be done at all. */
        if (eigrp->maxsndbuflen >= buflen)
                return;
-       frr_elevate_privs(&eigrpd_privs) {
 
        /* Now we try to set SO_SNDBUF to what our caller has requested
         * (the MTU of a newly added interface). However, if the OS has
@@ -117,16 +121,15 @@ void eigrp_adjust_sndbuflen(struct eigrp *eigrp, unsigned int buflen)
         * may allocate more buffer space, than requested, this isn't
         * a error.
         */
-               setsockopt_so_sendbuf(eigrp->fd, buflen);
-               newbuflen = getsockopt_so_sendbuf(eigrp->fd);
-               if (newbuflen < 0 || newbuflen < (int)buflen)
-                       zlog_warn("%s: tried to set SO_SNDBUF to %u, but got %d",
-                                 __func__, buflen, newbuflen);
-               if (newbuflen >= 0)
-                       eigrp->maxsndbuflen = (unsigned int)newbuflen;
-               else
-                       zlog_warn("%s: failed to get SO_SNDBUF", __func__);
-       }
+       setsockopt_so_sendbuf(eigrp->fd, buflen);
+       newbuflen = getsockopt_so_sendbuf(eigrp->fd);
+       if (newbuflen < 0 || newbuflen < (int)buflen)
+               zlog_warn("%s: tried to set SO_SNDBUF to %u, but got %d",
+                         __func__, buflen, newbuflen);
+       if (newbuflen >= 0)
+               eigrp->maxsndbuflen = (unsigned int)newbuflen;
+       else
+               zlog_warn("%s: failed to get SO_SNDBUF", __func__);
 }
 
 int eigrp_if_ipmulticast(struct eigrp *top, struct prefix *p,
@@ -211,7 +214,7 @@ int eigrp_if_drop_allspfrouters(struct eigrp *top, struct prefix *p,
 
 int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
 {
-       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+       struct vrf *vrf = vrf_lookup_by_id(eigrp->vrf_id);
        struct route_node *rn;
        struct interface *ifp;
 
@@ -292,6 +295,9 @@ void eigrp_if_update(struct interface *ifp)
         * we need to check eac one and add the interface as approperate
         */
        for (ALL_LIST_ELEMENTS(eigrp_om->eigrp, node, nnode, eigrp)) {
+               if (ifp->vrf_id != eigrp->vrf_id)
+                       continue;
+
                /* EIGRP must be on and Router-ID must be configured. */
                if (eigrp->router_id.s_addr == 0)
                        continue;