Exemplo n.º 1
0
/* Delete IPv6 route from the kernel. */
int
kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate,
                        int index, int flags, int table)
{
    return netlink_route (RTM_DELROUTE, AF_INET6, &dest->prefix, dest->prefixlen,
                          gate, index, flags, table);
}
Exemplo n.º 2
0
void netlink_process(struct ufpd_thread *thread,
	uint8_t *read_buf, int read_size)
{
	struct nlmsghdr *nlh;

	nlh = (struct nlmsghdr *)read_buf;

	while(NLMSG_OK(nlh, read_size)){
		switch(nlh->nlmsg_type){
		case RTM_NEWROUTE:
		case RTM_DELROUTE:
			netlink_route(thread, nlh);
			break;
		case RTM_NEWNEIGH:
		case RTM_DELNEIGH:
			netlink_neigh(thread, nlh);
			break;
		default:
			ufpd_log(LOG_ERR, "unknown type netlink message");
			break;
		}

		nlh = NLMSG_NEXT(nlh, read_size);
	}

	return;
}
Exemplo n.º 3
0
/* Add/Delete a list of IP routes */
void
netlink_rtlist(list rt_list, int cmd)
{
	ip_route_t *iproute;
	element e;

	/* No routes to add */
	if (LIST_ISEMPTY(rt_list))
		return;

	for (e = LIST_HEAD(rt_list); e; ELEMENT_NEXT(e)) {
		iproute = ELEMENT_DATA(e);
		if ((cmd == IPROUTE_DEL) == iproute->set) {
			if (netlink_route(iproute, cmd) > 0)
				iproute->set = (cmd == IPROUTE_ADD);
			else
				iproute->set = false;
		}
	}
}
Exemplo n.º 4
0
/* Add/Delete a list of IP routes */
void
netlink_rtlist(list rt_list, int cmd)
{
	ip_route_t *iproute;
	element e;

	/* No routes to add */
	if (LIST_ISEMPTY(rt_list))
		return;

	for (e = LIST_HEAD(rt_list); e; ELEMENT_NEXT(e)) {
		iproute = ELEMENT_DATA(e);
		if ((cmd && !iproute->set) ||
		    (!cmd && iproute->set)) {
			if (netlink_route(iproute, cmd) > 0)
				iproute->set = (cmd) ? 1 : 0;
			else
				iproute->set = 0;
		}
	}
}