Skip to content

Commit

Permalink
eigrpd: Create a socket per vrf for communication
Browse files Browse the repository at this point in the history
Setup EIGRP to use a socket per vrf for communication
amongst it's peers.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp authored and rzalamena committed Aug 7, 2019
1 parent c20fa24 commit 128ed76
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions eigrpd/eigrp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrp_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down
6 changes: 3 additions & 3 deletions eigrpd/eigrpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 128ed76

Please sign in to comment.