+// SPDX-License-Identifier: MIT
/*
Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
*/
#include <zebra.h>
int babel_ifp_up(struct interface *ifp)
{
- debugf(BABEL_DEBUG_IF, "receive a 'interface up'");
+ debugf(BABEL_DEBUG_IF, "receive an 'interface up'");
interface_recalculate(ifp);
return 0;
int
babel_ifp_down(struct interface *ifp)
{
- debugf(BABEL_DEBUG_IF, "receive a 'interface down'");
+ debugf(BABEL_DEBUG_IF, "receive an 'interface down'");
if (ifp == NULL) {
return 0;
int babel_ifp_create (struct interface *ifp)
{
- debugf(BABEL_DEBUG_IF, "receive a 'interface add'");
+ debugf(BABEL_DEBUG_IF, "receive an 'interface add'");
interface_recalculate(ifp);
int
babel_ifp_destroy(struct interface *ifp)
{
- debugf(BABEL_DEBUG_IF, "receive a 'interface delete'");
+ debugf(BABEL_DEBUG_IF, "receive an 'interface delete'");
if (IS_ENABLE(ifp))
interface_reset(ifp);
struct connected *ifc;
struct prefix *prefix;
- debugf(BABEL_DEBUG_IF, "receive a 'interface address add'");
+ debugf(BABEL_DEBUG_IF, "receive an 'interface address add'");
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
zclient->ibuf, vrf_id);
struct connected *ifc;
struct prefix *prefix;
- debugf(BABEL_DEBUG_IF, "receive a 'interface address delete'");
+ debugf(BABEL_DEBUG_IF, "receive an 'interface address delete'");
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
zclient->ibuf, vrf_id);
babel_set_wired_internal(babel_interface_nfo *babel_ifp, int wired)
{
if(wired) {
- babel_ifp->flags |= BABEL_IF_WIRED;
- babel_ifp->flags |= BABEL_IF_SPLIT_HORIZON;
+ SET_FLAG(babel_ifp->flags, BABEL_IF_WIRED);
+ SET_FLAG(babel_ifp->flags, BABEL_IF_SPLIT_HORIZON);
babel_ifp->cost = BABEL_DEFAULT_RXCOST_WIRED;
babel_ifp->channel = BABEL_IF_CHANNEL_NONINTERFERING;
- babel_ifp->flags &= ~BABEL_IF_LQ;
- } else {
- babel_ifp->flags &= ~BABEL_IF_WIRED;
- babel_ifp->flags &= ~BABEL_IF_SPLIT_HORIZON;
+ UNSET_FLAG(babel_ifp->flags, BABEL_IF_LQ);
+ }
+ else {
+ UNSET_FLAG(babel_ifp->flags, BABEL_IF_WIRED);
+ UNSET_FLAG(babel_ifp->flags, BABEL_IF_SPLIT_HORIZON);
babel_ifp->cost = BABEL_DEFAULT_RXCOST_WIRELESS;
babel_ifp->channel = BABEL_IF_CHANNEL_INTERFERING;
- babel_ifp->flags |= BABEL_IF_LQ;
+ SET_FLAG(babel_ifp->flags, BABEL_IF_LQ);
}
}
return -1;
}
- babel_ifp->flags |= BABEL_IF_IS_UP;
+ SET_FLAG(babel_ifp->flags, BABEL_IF_IS_UP);
mtu = MIN(ifp->mtu, ifp->mtu6);
rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
(char*)&mreq, sizeof(mreq));
- if(rc < 0) {
- flog_err_sys(EC_LIB_SOCKET,
- "setsockopt(IPV6_JOIN_GROUP) on interface '%s': %s",
- ifp->name, safe_strerror(errno));
- /* This is probably due to a missing link-local address,
- so down this interface, and wait until the main loop
- tries to up it again. */
- interface_reset(ifp);
- return -1;
+ if (rc < 0 && errno != EADDRINUSE) {
+ flog_err_sys(EC_LIB_SOCKET,
+ "setsockopt(IPV6_JOIN_GROUP) on interface '%s': %s",
+ ifp->name, safe_strerror(errno));
+ /* This is probably due to a missing link-local address,
+ so down this interface, and wait until the main loop
+ tries to up it again. */
+ interface_reset(ifp);
+ return -1;
}
set_timeout(&babel_ifp->hello_timeout, babel_ifp->hello_interval);
debugf(BABEL_DEBUG_COMMON,
"Upped interface %s (%s, cost=%d, channel=%d%s).",
ifp->name,
- (babel_ifp->flags & BABEL_IF_WIRED) ? "wired" : "wireless",
+ CHECK_FLAG(babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless",
babel_ifp->cost,
babel_ifp->channel,
babel_ifp->ipv4 ? ", IPv4" : "");
struct ipv6_mreq mreq;
babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
- if (!(babel_ifp->flags & BABEL_IF_IS_UP))
+ if (!CHECK_FLAG(babel_ifp->flags, BABEL_IF_IS_UP))
return 0;
debugf(BABEL_DEBUG_IF, "interface reset: %s", ifp->name);
- babel_ifp->flags &= ~BABEL_IF_IS_UP;
+
+ UNSET_FLAG(babel_ifp->flags, BABEL_IF_IS_UP);
flush_interface_routes(ifp, 0);
babel_ifp->buffered = 0;
debugf(BABEL_DEBUG_COMMON,"Upped network %s (%s, cost=%d%s).",
ifp->name,
- (babel_ifp->flags & BABEL_IF_WIRED) ? "wired" : "wireless",
+ CHECK_FLAG(babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless",
babel_ifp->cost,
babel_ifp->ipv4 ? ", IPv4" : "");