Project

General

Profile

Submit #2960 ยป carp.diff

fgudin, 10/26/2016 06:02 AM

View differences:

sys/netinet/ip_carp.c
327 327

  
328 328
SYSCTL_DECL(_net_inet_carp);
329 329

  
330
static int carp_opts[CARPCTL_MAXID] = { 0, 1, 0, 1, 0, 0 }; /* XXX for now */
330
static int carp_opts[CARPCTL_MAXID] = { 0, 1, 0, 1, 0, 0, 1 }; /* XXX for now */
331 331
SYSCTL_INT(_net_inet_carp, CARPCTL_ALLOW, allow, CTLFLAG_RW,
332 332
    &carp_opts[CARPCTL_ALLOW], 0, "Accept incoming CARP packets");
333 333
SYSCTL_INT(_net_inet_carp, CARPCTL_PREEMPT, preempt, CTLFLAG_RW,
......
336 336
    &carp_opts[CARPCTL_LOG], 0, "log bad carp packets");
337 337
SYSCTL_INT(_net_inet_carp, CARPCTL_ARPBALANCE, arpbalance, CTLFLAG_RW,
338 338
    &carp_opts[CARPCTL_ARPBALANCE], 0, "balance arp responses");
339
SYSCTL_INT(_net_inet_carp, CARPCTL_SETROUTE, setroute, CTLFLAG_RW,
340
    &carp_opts[CARPCTL_SETROUTE], 0, "set route");
339 341

  
340 342
static int carp_suppress_preempt = 0;
341 343
SYSCTL_INT(_net_inet_carp, OID_AUTO, suppress_preempt, CTLFLAG_RD,
......
1172 1174
			   cifp->if_xname);
1173 1175
			carp_set_state(sc, BACKUP);
1174 1176
			carp_setrun(sc, 0);
1175
			carp_setroute(sc, RTM_DELETE);
1177
			if (carp_opts[CARPCTL_SETROUTE]) {
1178
				carp_setroute(sc, RTM_DELETE);
1179
			}
1176 1180
		}
1177 1181
		break;
1178 1182

  
......
1751 1755
		carp_send_na(sc);
1752 1756
#endif /* INET6 */
1753 1757
		carp_setrun(sc, 0);
1754
		carp_setroute(sc, RTM_ADD);
1758
		if (carp_opts[CARPCTL_SETROUTE]) {
1759
			carp_setroute(sc, RTM_ADD);
1760
		}
1755 1761
		break;
1756 1762
	}
1757 1763
}
......
1775 1781
	    (sc->sc_naddrs || sc->sc_naddrs6)) {
1776 1782
		/* Nothing */
1777 1783
	} else {
1778
		carp_setroute(sc, RTM_DELETE);
1784
		if (carp_opts[CARPCTL_SETROUTE]) {
1785
			carp_setroute(sc, RTM_DELETE);
1786
		}
1779 1787
		return;
1780 1788
	}
1781 1789

  
......
1790 1798
			CARP_DEBUG("%s: INIT -> MASTER (preempting)\n",
1791 1799
				   cifp->if_xname);
1792 1800
			carp_set_state(sc, MASTER);
1793
			carp_setroute(sc, RTM_ADD);
1801
			if (carp_opts[CARPCTL_SETROUTE]) {
1802
				carp_setroute(sc, RTM_ADD);
1803
			}
1794 1804
		} else {
1795 1805
			CARP_DEBUG("%s: INIT -> BACKUP\n", cifp->if_xname);
1796 1806
			carp_set_state(sc, BACKUP);
1797
			carp_setroute(sc, RTM_DELETE);
1807
			if (carp_opts[CARPCTL_SETROUTE]) {
1808
				carp_setroute(sc, RTM_DELETE);
1809
			}
1798 1810
			carp_setrun(sc, 0);
1799 1811
		}
1800 1812
		break;
......
2413 2425
			callout_stop(&sc->sc_ad_tmo);
2414 2426
			carp_set_state(sc, BACKUP);
2415 2427
			carp_setrun(sc, 0);
2416
			carp_setroute(sc, RTM_DELETE);
2428
			if (carp_opts[CARPCTL_SETROUTE]) {
2429
				carp_setroute(sc, RTM_DELETE);
2430
			}
2417 2431
			break;
2418 2432

  
2419 2433
		case MASTER:
sys/netinet/ip_carp.h
157 157
#define	CARPCTL_LOG		3	/* log bad packets */
158 158
#define	CARPCTL_STATS		4	/* statistics (read-only) */
159 159
#define	CARPCTL_ARPBALANCE	5	/* balance arp responses */
160
#define	CARPCTL_MAXID		6
160
#define	CARPCTL_SETROUTE	6	/* change routes */
161
#define	CARPCTL_MAXID		7
161 162

  
162 163
#define	CARPCTL_NAMES { \
163 164
	{ 0, 0 }, \
......
166 167
	{ "log", CTLTYPE_INT }, \
167 168
	{ "stats", CTLTYPE_STRUCT }, \
168 169
	{ "arpbalance", CTLTYPE_INT }, \
170
	{ "setroute", CTLTYPE_INT }, \
169 171
}
170 172

  
171 173
#ifdef _KERNEL
    (1-1/1)