mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 09:20:25 +00:00
pimd: Move thread read to struct pim_instance
When we are handling the thread read/writes for a pim mroute socket, make it so that it can be appropriately handled by the 'struct pim_instance' instead of defaulting to the default VRF's Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
cdbfaec57b
commit
8ea5d94477
@ -41,10 +41,7 @@
|
||||
#include "pim_zlookup.h"
|
||||
#include "pim_ssm.h"
|
||||
|
||||
/* GLOBAL VARS */
|
||||
static struct thread *qpim_mroute_socket_reader = NULL;
|
||||
|
||||
static void mroute_read_on(void);
|
||||
static void mroute_read_on(struct pim_instance *pim);
|
||||
|
||||
static int pim_mroute_set(struct pim_instance *pim, int enable)
|
||||
{
|
||||
@ -626,17 +623,17 @@ int pim_mroute_msg(int fd, const char *buf, int buf_size)
|
||||
|
||||
static int mroute_read(struct thread *t)
|
||||
{
|
||||
struct pim_instance *pim;
|
||||
static long long count;
|
||||
char buf[10000];
|
||||
int result = 0;
|
||||
int cont = 1;
|
||||
int fd;
|
||||
int rd;
|
||||
|
||||
fd = THREAD_FD(t);
|
||||
pim = THREAD_ARG(t);
|
||||
|
||||
while (cont) {
|
||||
rd = read(fd, buf, sizeof(buf));
|
||||
rd = read(pim->mroute_socket, buf, sizeof(buf));
|
||||
if (rd <= 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
@ -646,12 +643,13 @@ static int mroute_read(struct thread *t)
|
||||
if (PIM_DEBUG_MROUTE)
|
||||
zlog_warn(
|
||||
"%s: failure reading rd=%d: fd=%d: errno=%d: %s",
|
||||
__PRETTY_FUNCTION__, rd, fd, errno,
|
||||
__PRETTY_FUNCTION__, rd,
|
||||
pim->mroute_socket, errno,
|
||||
safe_strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = pim_mroute_msg(fd, buf, rd);
|
||||
result = pim_mroute_msg(pim->mroute_socket, buf, rd);
|
||||
|
||||
count++;
|
||||
if (count % qpim_packet_process == 0)
|
||||
@ -659,20 +657,20 @@ static int mroute_read(struct thread *t)
|
||||
}
|
||||
/* Keep reading */
|
||||
done:
|
||||
mroute_read_on();
|
||||
mroute_read_on(pim);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void mroute_read_on()
|
||||
static void mroute_read_on(struct pim_instance *pim)
|
||||
{
|
||||
thread_add_read(master, mroute_read, 0, pimg->mroute_socket,
|
||||
&qpim_mroute_socket_reader);
|
||||
&pim->thread);
|
||||
}
|
||||
|
||||
static void mroute_read_off()
|
||||
static void mroute_read_off(struct pim_instance *pim)
|
||||
{
|
||||
THREAD_OFF(qpim_mroute_socket_reader);
|
||||
THREAD_OFF(pim->thread);
|
||||
}
|
||||
|
||||
int pim_mroute_socket_enable(struct pim_instance *pim)
|
||||
@ -707,7 +705,7 @@ int pim_mroute_socket_enable(struct pim_instance *pim)
|
||||
|
||||
pim->mroute_socket_creation = pim_time_monotonic_sec();
|
||||
|
||||
mroute_read_on();
|
||||
mroute_read_on(pim);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -727,7 +725,7 @@ int pim_mroute_socket_disable(struct pim_instance *pim)
|
||||
return -3;
|
||||
}
|
||||
|
||||
mroute_read_off();
|
||||
mroute_read_off(pim);
|
||||
pim->mroute_socket = -1;
|
||||
|
||||
return 0;
|
||||
|
@ -251,6 +251,7 @@ struct pim_instance {
|
||||
|
||||
int send_v6_secondary;
|
||||
|
||||
struct thread *thread;
|
||||
int mroute_socket;
|
||||
int64_t mroute_socket_creation;
|
||||
int64_t mroute_add_events;
|
||||
|
Loading…
Reference in New Issue
Block a user