summaryrefslogtreecommitdiffstats
path: root/eigrpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-06-15 19:10:05 +0200
committerRafael Zalamena <rzalamena@opensourcerouting.org>2019-08-07 02:45:14 +0200
commit128ed7604d0d90de1e49a847cc4aa4f585b2b7c5 (patch)
tree62c33ac55c771b4a4a26e93a04f0652c59714db3 /eigrpd
parenteigrpd: Add various vrf handling functions (diff)
downloadfrr-128ed7604d0d90de1e49a847cc4aa4f585b2b7c5.tar.xz
frr-128ed7604d0d90de1e49a847cc4aa4f585b2b7c5.zip
eigrpd: Create a socket per vrf for communication
Setup EIGRP to use a socket per vrf for communication amongst it's peers. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'eigrpd')
-rw-r--r--eigrpd/eigrp_network.c6
-rw-r--r--eigrpd/eigrp_network.h2
-rw-r--r--eigrpd/eigrp_structs.h2
-rw-r--r--eigrpd/eigrpd.c6
4 files changed, 9 insertions, 7 deletions
diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c
index bbb9487b4..95cf948d0 100644
--- a/eigrpd/eigrp_network.c
+++ b/eigrpd/eigrp_network.c
@@ -53,7 +53,7 @@ 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 ret;
@@ -62,7 +62,9 @@ int eigrp_sock_init(void)
#endif
frr_elevate_privs(&eigrpd_privs) {
- eigrp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_EIGRPIGP);
+ 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));
diff --git a/eigrpd/eigrp_network.h b/eigrpd/eigrp_network.h
index b3c76bbec..7839fc946 100644
--- a/eigrpd/eigrp_network.h
+++ b/eigrpd/eigrp_network.h
@@ -30,7 +30,7 @@
/* Prototypes */
-extern int eigrp_sock_init(void);
+extern int eigrp_sock_init(struct vrf *vrf);
extern int eigrp_if_ipmulticast(struct eigrp *, struct prefix *, unsigned int);
extern int eigrp_network_set(struct eigrp *eigrp, struct prefix *p);
extern int eigrp_network_unset(struct eigrp *eigrp, struct prefix *p);
diff --git a/eigrpd/eigrp_structs.h b/eigrpd/eigrp_structs.h
index 848fc4f2b..e50858f07 100644
--- a/eigrpd/eigrp_structs.h
+++ b/eigrpd/eigrp_structs.h
@@ -87,7 +87,7 @@ struct eigrp {
struct list *eiflist; /* eigrp interfaces */
uint8_t passive_interface_default; /* passive-interface default */
- unsigned int fd;
+ int fd;
unsigned int maxsndbuflen;
uint32_t sequence_number; /*Global EIGRP sequence number*/
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index b4bacdc36..6b93fe664 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -137,7 +137,6 @@ void eigrp_master_init(void)
static struct eigrp *eigrp_new(const char *AS, vrf_id_t vrf_id)
{
struct eigrp *eigrp = XCALLOC(MTYPE_EIGRP_TOP, sizeof(struct eigrp));
- int eigrp_socket;
/* init information relevant to peers */
eigrp->vrf_id = vrf_id;
@@ -160,14 +159,15 @@ static struct eigrp *eigrp_new(const char *AS, vrf_id_t vrf_id)
eigrp->passive_interface_default = EIGRP_IF_ACTIVE;
eigrp->networks = eigrp_topology_new();
- if ((eigrp_socket = eigrp_sock_init()) < 0) {
+ eigrp->fd = eigrp_sock_init(vrf_lookup_by_id(vrf_id));
+
+ if (eigrp->fd < 0) {
flog_err_sys(
EC_LIB_SOCKET,
"eigrp_new: fatal error: eigrp_sock_init was unable to open a socket");
exit(1);
}
- eigrp->fd = eigrp_socket;
eigrp->maxsndbuflen = getsockopt_so_sendbuf(eigrp->fd);
eigrp->ibuf = stream_new(EIGRP_PACKET_MAX_LEN + 1);