Project

General

Profile

Submit #2960 ยป carp.diff

fgudin, 10/26/2016 06:02 AM

View differences:

sys/netinet/ip_carp.c
SYSCTL_DECL(_net_inet_carp);
static int carp_opts[CARPCTL_MAXID] = { 0, 1, 0, 1, 0, 0 }; /* XXX for now */
static int carp_opts[CARPCTL_MAXID] = { 0, 1, 0, 1, 0, 0, 1 }; /* XXX for now */
SYSCTL_INT(_net_inet_carp, CARPCTL_ALLOW, allow, CTLFLAG_RW,
&carp_opts[CARPCTL_ALLOW], 0, "Accept incoming CARP packets");
SYSCTL_INT(_net_inet_carp, CARPCTL_PREEMPT, preempt, CTLFLAG_RW,
......
&carp_opts[CARPCTL_LOG], 0, "log bad carp packets");
SYSCTL_INT(_net_inet_carp, CARPCTL_ARPBALANCE, arpbalance, CTLFLAG_RW,
&carp_opts[CARPCTL_ARPBALANCE], 0, "balance arp responses");
SYSCTL_INT(_net_inet_carp, CARPCTL_SETROUTE, setroute, CTLFLAG_RW,
&carp_opts[CARPCTL_SETROUTE], 0, "set route");
static int carp_suppress_preempt = 0;
SYSCTL_INT(_net_inet_carp, OID_AUTO, suppress_preempt, CTLFLAG_RD,
......
cifp->if_xname);
carp_set_state(sc, BACKUP);
carp_setrun(sc, 0);
carp_setroute(sc, RTM_DELETE);
if (carp_opts[CARPCTL_SETROUTE]) {
carp_setroute(sc, RTM_DELETE);
}
}
break;
......
carp_send_na(sc);
#endif /* INET6 */
carp_setrun(sc, 0);
carp_setroute(sc, RTM_ADD);
if (carp_opts[CARPCTL_SETROUTE]) {
carp_setroute(sc, RTM_ADD);
}
break;
}
}
......
(sc->sc_naddrs || sc->sc_naddrs6)) {
/* Nothing */
} else {
carp_setroute(sc, RTM_DELETE);
if (carp_opts[CARPCTL_SETROUTE]) {
carp_setroute(sc, RTM_DELETE);
}
return;
}
......
CARP_DEBUG("%s: INIT -> MASTER (preempting)\n",
cifp->if_xname);
carp_set_state(sc, MASTER);
carp_setroute(sc, RTM_ADD);
if (carp_opts[CARPCTL_SETROUTE]) {
carp_setroute(sc, RTM_ADD);
}
} else {
CARP_DEBUG("%s: INIT -> BACKUP\n", cifp->if_xname);
carp_set_state(sc, BACKUP);
carp_setroute(sc, RTM_DELETE);
if (carp_opts[CARPCTL_SETROUTE]) {
carp_setroute(sc, RTM_DELETE);
}
carp_setrun(sc, 0);
}
break;
......
callout_stop(&sc->sc_ad_tmo);
carp_set_state(sc, BACKUP);
carp_setrun(sc, 0);
carp_setroute(sc, RTM_DELETE);
if (carp_opts[CARPCTL_SETROUTE]) {
carp_setroute(sc, RTM_DELETE);
}
break;
case MASTER:
sys/netinet/ip_carp.h
#define CARPCTL_LOG 3 /* log bad packets */
#define CARPCTL_STATS 4 /* statistics (read-only) */
#define CARPCTL_ARPBALANCE 5 /* balance arp responses */
#define CARPCTL_MAXID 6
#define CARPCTL_SETROUTE 6 /* change routes */
#define CARPCTL_MAXID 7
#define CARPCTL_NAMES { \
{ 0, 0 }, \
......
{ "log", CTLTYPE_INT }, \
{ "stats", CTLTYPE_STRUCT }, \
{ "arpbalance", CTLTYPE_INT }, \
{ "setroute", CTLTYPE_INT }, \
}
#ifdef _KERNEL
    (1-1/1)