(hardcoded now as /var/run/charon.vici).
strongSwan currently needs few patches applied. Please check out the
-`http://git.alpinelinux.org/cgit/user/tteras/strongswan/log/?h=tteras-release,release <http://git.alpinelinux.org/cgit/user/tteras/strongswan/log/?h=tteras-release,release>`_
+https://git.alpinelinux.org/user/tteras/strongswan/log/?h=tteras-release
and
-`http://git.alpinelinux.org/cgit/user/tteras/strongswan/log/?h=tteras,working tree <http://git.alpinelinux.org/cgit/user/tteras/strongswan/log/?h=tteras,working tree>`_
+https://git.alpinelinux.org/user/tteras/strongswan/log/?h=tteras
git repositories for the patches.
.. _nhrp-events:
/* Daemons lists */
#define DAEMONS_STR \
- "For the zebra daemon\nFor the rip daemon\nFor the ripng daemon\nFor the ospf daemon\nFor the ospfv6 daemon\nFor the bgp daemon\nFor the isis daemon\nFor the pbr daemon\nFor the fabricd daemon\nFor the pim daemon\nFor the static daemon\nFor the sharpd daemon\nFor the vrrpd daemon\n"
+ "For the zebra daemon\nFor the rip daemon\nFor the ripng daemon\nFor the ospf daemon\nFor the ospfv6 daemon\nFor the bgp daemon\nFor the isis daemon\nFor the pbr daemon\nFor the fabricd daemon\nFor the pim daemon\nFor the static daemon\nFor the sharpd daemon\nFor the vrrpd daemon\nFor the ldpd daemon\n"
#define DAEMONS_LIST \
- "<zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd|fabricd|pimd|staticd|sharpd|vrrpd>"
+ "<zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd|fabricd|pimd|staticd|sharpd|vrrpd|ldpd>"
/* Prototypes. */
extern void install_node(struct cmd_node *, int (*)(struct vty *));
return;
}
-#ifdef ORIGINAL_CODING
- zlog_debug(
- "msg=%p msgtype=%d msglen=%d msgseq=%d streamdata=%p streamsize=%lu\n",
- msg, msg->hdr.msgtype, ntohs(msg->hdr.msglen),
- ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
- STREAM_SIZE(msg->s));
-#else /* ORIGINAL_CODING */
/* API message common header part. */
zlog_debug("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%zd)",
ospf_api_typename(msg->hdr.msgtype), msg->hdr.msgtype,
(unsigned long)ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
STREAM_SIZE(msg->s));
-/* API message body part. */
-#ifdef ndef
- /* Generic Hex/Ascii dump */
- DumpBuf(STREAM_DATA(msg->s), STREAM_SIZE(msg->s)); /* Sorry, deleted! */
-#else /* ndef */
-/* Message-type dependent dump function. */
-#endif /* ndef */
-
return;
-#endif /* ORIGINAL_CODING */
}
void msg_free(struct msg *msg)
* Power2[0] is not used. */
-#ifdef ORIGINAL_CODING
-static const uint16_t Power2[] = {0x0, 0x1, 0x2, 0x4, 0x8, 0x10,
- 0x20, 0x40, 0x80, 0x100, 0x200, 0x400,
- 0x800, 0x1000, 0x2000, 0x4000, 0x8000};
-#else
static const uint16_t Power2[] = {
0, (1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4),
(1 << 5), (1 << 6), (1 << 7), (1 << 8), (1 << 9), (1 << 10),
(1 << 11), (1 << 12), (1 << 13), (1 << 14), (1 << 15)};
-#endif /* ORIGINAL_CODING */
struct lsa_filter_type {
uint16_t typemask; /* bitmask for selecting LSA types (1..16) */
/* Update ASBR status. */
void ospf_asbr_status_update(struct ospf *ospf, uint8_t status)
{
- zlog_info("ASBR[Status:%d]: Update", status);
+ zlog_info("ASBR[%s:Status:%d]: Update",
+ ospf_get_name(ospf), status);
/* ASBR on. */
if (status) {
/* Already ASBR. */
if (IS_OSPF_ASBR(ospf)) {
- zlog_info("ASBR[Status:%d]: Already ASBR", status);
+ zlog_info("ASBR[%s:Status:%d]: Already ASBR",
+ ospf_get_name(ospf), status);
return;
}
SET_FLAG(ospf->flags, OSPF_FLAG_ASBR);
} else {
/* Already non ASBR. */
if (!IS_OSPF_ASBR(ospf)) {
- zlog_info("ASBR[Status:%d]: Already non ASBR", status);
+ zlog_info("ASBR[%s:Status:%d]: Already non ASBR",
+ ospf_get_name(ospf), status);
return;
}
UNSET_FLAG(ospf->flags, OSPF_FLAG_ASBR);
stream_set_getp(s, sp);
}
-/* Expects header to be in host order */
-void ospf_ip_header_dump(struct ip *iph)
-{
- /* IP Header dump. */
- zlog_debug("ip_v %d", iph->ip_v);
- zlog_debug("ip_hl %d", iph->ip_hl);
- zlog_debug("ip_tos %d", iph->ip_tos);
- zlog_debug("ip_len %d", iph->ip_len);
- zlog_debug("ip_id %u", (uint32_t)iph->ip_id);
- zlog_debug("ip_off %u", (uint32_t)iph->ip_off);
- zlog_debug("ip_ttl %d", iph->ip_ttl);
- zlog_debug("ip_p %d", iph->ip_p);
- zlog_debug("ip_sum 0x%x", (uint32_t)iph->ip_sum);
- zlog_debug("ip_src %s", inet_ntoa(iph->ip_src));
- zlog_debug("ip_dst %s", inet_ntoa(iph->ip_dst));
-}
-
static void ospf_header_dump(struct ospf_header *ospfh)
{
char buf[9];
(conf_debug_ospf_packet[a] & OSPF_DEBUG_##b)
#define IS_CONF_DEBUG_OSPF(a, b) (conf_debug_ospf_##a & OSPF_DEBUG_##b)
-#ifdef ORIGINAL_CODING
-#else /* ORIGINAL_CODING */
-struct stream;
-#endif /* ORIGINAL_CODING */
-
#define AREA_NAME(A) ospf_area_name_string ((A))
#define IF_NAME(I) ospf_if_name_string ((I))
extern void ospf_nbr_state_message(struct ospf_neighbor *, char *, size_t);
extern const char *ospf_timer_dump(struct thread *, char *, size_t);
extern const char *ospf_timeval_dump(struct timeval *, char *, size_t);
-extern void ospf_ip_header_dump(struct ip *);
extern void ospf_packet_dump(struct stream *);
extern void ospf_debug_init(void);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "LSA[Type%d:%s]: Process self-originated LSA seq 0x%x",
- new->data->type, inet_ntoa(new->data->id),
- ntohl(new->data->ls_seqnum));
+ "%s:LSA[Type%d:%s]: Process self-originated LSA seq 0x%x",
+ ospf_get_name(ospf), new->data->type,
+ inet_ntoa(new->data->id), ntohl(new->data->ls_seqnum));
/* If we're here, we installed a self-originated LSA that we received
from a neighbor, i.e. it's more recent. We must see whether we want
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]",
- inet_ntoa(nbr->router_id),
+ "%s:LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]",
+ ospf_get_name(ospf), inet_ntoa(nbr->router_id),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
(void *)current, dump_lsa_key(new));
== OSPF_INITIAL_SEQUENCE_NUMBER)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "LSA[Flooding]: Got a self-originated LSA, "
- "while local one is initial instance.");
+ "%s:LSA[Flooding]: Got a self-originated LSA, while local one is initial instance.",
+ ospf_get_name(ospf));
; /* Accept this LSA for quick LSDB resynchronization.
*/
} else if (monotime_since(¤t->tv_recv, NULL)
< ospf->min_ls_arrival * 1000LL) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "LSA[Flooding]: LSA is received recently.");
+ "%s:LSA[Flooding]: LSA is received recently.",
+ ospf_get_name(ospf));
return -1;
}
}
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_flood_through_interface(): "
- "considering int %s, INBR(%s), LSA[%s] AGE %u",
- IF_NAME(oi), inbr ? inet_ntoa(inbr->router_id) : "NULL",
+ "%s:ospf_flood_through_interface(): considering int %s, INBR(%s), LSA[%s] AGE %u",
+ ospf_get_name(oi->ospf), IF_NAME(oi), inbr ? inet_ntoa(inbr->router_id) : "NULL",
dump_lsa_key(lsa), ntohs(lsa->data->ls_age));
if (!ospf_if_is_enable(oi))
onbr = rn->info;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_flood_through_interface(): considering nbr %s (%s)",
+ "ospf_flood_through_interface(): considering nbr %s(%s) (%s)",
inet_ntoa(onbr->router_id),
+ ospf_get_name(oi->ospf),
lookup_msg(ospf_nsm_state_msg, onbr->state,
NULL));
}
}
-/* If the new LSA was received from this neighbor,
- examine the next neighbor. */
-#ifdef ORIGINAL_CODING
- if (inbr)
- if (IPV4_ADDR_SAME(&inbr->router_id, &onbr->router_id))
- continue;
-#else /* ORIGINAL_CODING */
+ /* If the new LSA was received from this neighbor,
+ examine the next neighbor. */
if (inbr) {
/*
* Triggered by LSUpd message parser "ospf_ls_upd ()".
continue;
}
}
-#endif /* ORIGINAL_CODING */
/* Add the new LSA to the Link state retransmission list
for the adjacency. The LSA will be retransmitted
{
int lsa_ack_flag = 0;
-/* Type-7 LSA's for NSSA are flooded throughout the AS here, and
- upon return are updated in the LSDB for Type-7's. Later,
- re-fresh will re-send them (and also, if ABR, packet code will
- translate to Type-5's)
+ /* Type-7 LSA's for NSSA are flooded throughout the AS here, and
+ upon return are updated in the LSDB for Type-7's. Later,
+ re-fresh will re-send them (and also, if ABR, packet code will
+ translate to Type-5's)
- As usual, Type-5 LSA's (if not DISCARDED because we are STUB or
- NSSA) are flooded throughout the AS, and are updated in the
- global table. */
-#ifdef ORIGINAL_CODING
- switch (lsa->data->type) {
- case OSPF_ROUTER_LSA:
- case OSPF_NETWORK_LSA:
- case OSPF_SUMMARY_LSA:
- case OSPF_ASBR_SUMMARY_LSA:
- case OSPF_OPAQUE_LINK_LSA: /* ospf_flood_through_interface ? */
- case OSPF_OPAQUE_AREA_LSA:
- lsa_ack_flag =
- ospf_flood_through_area(inbr->oi->area, inbr, lsa);
- break;
- case OSPF_AS_EXTERNAL_LSA: /* Type-5 */
- case OSPF_OPAQUE_AS_LSA:
- lsa_ack_flag = ospf_flood_through_as(ospf, inbr, lsa);
- break;
- /* Type-7 Only received within NSSA, then flooded */
- case OSPF_AS_NSSA_LSA:
- /* Any P-bit was installed with the Type-7. */
- lsa_ack_flag =
- ospf_flood_through_area(inbr->oi->area, inbr, lsa);
-
- if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_flood_through: LOCAL NSSA FLOOD of Type-7.");
- break;
- default:
- break;
- }
-#else /* ORIGINAL_CODING */
+ As usual, Type-5 LSA's (if not DISCARDED because we are STUB or
+ NSSA) are flooded throughout the AS, and are updated in the
+ global table. */
/*
* At the common sub-sub-function "ospf_flood_through_interface()",
* a parameter "inbr" will be used to distinguish the called context
lsa_ack_flag = ospf_flood_through_area(lsa->area, inbr, lsa);
break;
}
-#endif /* ORIGINAL_CODING */
return (lsa_ack_flag);
}
* the common function "ospf_lsdb_add()" -- endo.
*/
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
- zlog_debug("RqstL(%lu)++, NBR(%s), LSA[%s]",
+ zlog_debug("RqstL(%lu)++, NBR(%s(%s)), LSA[%s]",
ospf_ls_request_count(nbr),
- inet_ntoa(nbr->router_id), dump_lsa_key(lsa));
+ inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa));
ospf_lsdb_add(&nbr->ls_req, lsa);
}
}
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */
- zlog_debug("RqstL(%lu)--, NBR(%s), LSA[%s]",
+ zlog_debug("RqstL(%lu)--, NBR(%s(%s)), LSA[%s]",
ospf_ls_request_count(nbr),
- inet_ntoa(nbr->router_id), dump_lsa_key(lsa));
+ inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa));
ospf_lsdb_delete(&nbr->ls_req, lsa);
}
if (ospf_lsa_more_recent(old, lsa) < 0) {
if (old) {
old->retransmit_counter--;
+ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
+ zlog_debug("RXmtL(%lu)--, NBR(%s(%s)), LSA[%s]",
+ ospf_ls_retransmit_count(nbr),
+ inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf),
+ dump_lsa_key(old));
ospf_lsdb_delete(&nbr->ls_rxmt, old);
}
lsa->retransmit_counter++;
* the common function "ospf_lsdb_add()" -- endo.
*/
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
- zlog_debug("RXmtL(%lu)++, NBR(%s), LSA[%s]",
+ zlog_debug("RXmtL(%lu)++, NBR(%s(%s)), LSA[%s]",
ospf_ls_retransmit_count(nbr),
inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf),
dump_lsa_key(lsa));
ospf_lsdb_add(&nbr->ls_rxmt, lsa);
}
if (ospf_ls_retransmit_lookup(nbr, lsa)) {
lsa->retransmit_counter--;
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */
- zlog_debug("RXmtL(%lu)--, NBR(%s), LSA[%s]",
+ zlog_debug("RXmtL(%lu)--, NBR(%s(%s)), LSA[%s]",
ospf_ls_retransmit_count(nbr),
inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf),
dump_lsa_key(lsa));
ospf_lsdb_delete(&nbr->ls_rxmt, lsa);
}
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: ospf interface %s vrf %s id %u created",
__PRETTY_FUNCTION__, ifp->name,
- ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id);
+ ospf_get_name(ospf), ospf->vrf_id);
return oi;
}
struct prefix_ipv4 *p;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_vl_new(): Start");
+ zlog_debug("ospf_vl_new()(%s): Start", ospf_get_name(ospf));
if (vlink_count == OSPF_VL_MAX_COUNT) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
return 0;
}
-#ifdef ORIGINAL_CODING
-void ospf_lsa_flush_self_originated(struct ospf_neighbor *nbr,
- struct ospf_lsa *self, struct ospf_lsa *new)
-{
- uint32_t seqnum;
-
- /* Adjust LS Sequence Number. */
- seqnum = ntohl(new->data->ls_seqnum) + 1;
- self->data->ls_seqnum = htonl(seqnum);
-
- /* Recalculate LSA checksum. */
- ospf_lsa_checksum(self->data);
-
- /* Reflooding LSA. */
- /* RFC2328 Section 13.3
- On non-broadcast networks, separate Link State Update
- packets must be sent, as unicasts, to each adjacent neighbor
- (i.e., those in state Exchange or greater). The destination
- IP addresses for these packets are the neighbors' IP
- addresses. */
- if (nbr->oi->type == OSPF_IFTYPE_NBMA) {
- struct route_node *rn;
- struct ospf_neighbor *onbr;
-
- for (rn = route_top(nbr->oi->nbrs); rn; rn = route_next(rn))
- if ((onbr = rn->info) != NULL)
- if (onbr != nbr->oi->nbr_self
- && onbr->status >= NSM_Exchange)
- ospf_ls_upd_send_lsa(
- onbr, self,
- OSPF_SEND_PACKET_DIRECT);
- } else
- ospf_ls_upd_send_lsa(nbr, self, OSPF_SEND_PACKET_INDIRECT);
-
- if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
- zlog_debug("LSA[Type%d:%s]: Flush self-originated LSA",
- self->data->type, inet_ntoa(self->data->id));
-}
-#else /* ORIGINAL_CODING */
int ospf_lsa_flush_schedule(struct ospf *ospf, struct ospf_lsa *lsa)
{
if (lsa == NULL || !IS_LSA_SELF(lsa))
return;
}
-#endif /* ORIGINAL_CODING */
/* If there is self-originated LSA, then return 1, otherwise return 0. */
/* An interface-independent version of ospf_lsa_is_self_originated */
nbr->t_inactivity = NULL;
if (IS_DEBUG_OSPF(nsm, NSM_TIMERS))
- zlog_debug("NSM[%s:%s]: Timer (Inactivity timer expire)",
- IF_NAME(nbr->oi), inet_ntoa(nbr->router_id));
+ zlog_debug("NSM[%s:%s:%s]: Timer (Inactivity timer expire)",
+ IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf));
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer);
nbr->t_db_desc = NULL;
if (IS_DEBUG_OSPF(nsm, NSM_TIMERS))
- zlog_debug("NSM[%s:%s]: Timer (DD Retransmit timer expire)",
- IF_NAME(nbr->oi), inet_ntoa(nbr->src));
+ zlog_debug("NSM[%s:%s:%s]: Timer (DD Retransmit timer expire)",
+ IF_NAME(nbr->oi), inet_ntoa(nbr->src),
+ ospf_get_name(nbr->oi->ospf));
/* resent last send DD packet. */
assert(nbr->last_send);
if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
zlog_debug(
- "NSM[%s:%s]: Down (PollIntervalTimer scheduled)",
+ "NSM[%s:%s:%s]: Down (PollIntervalTimer scheduled)",
IF_NAME(nbr->oi),
- inet_ntoa(nbr->address.u.prefix4));
+ inet_ntoa(nbr->address.u.prefix4),
+ ospf_get_name(nbr->oi->ospf));
}
return 0;
{
/* Logging change of status. */
if (IS_DEBUG_OSPF(nsm, NSM_STATUS))
- zlog_debug("NSM[%s:%s]: State change %s -> %s (%s)",
+ zlog_debug("NSM[%s:%s:%s]: State change %s -> %s (%s)",
IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
lookup_msg(ospf_nsm_state_msg, next_state, NULL),
ospf_nsm_event_str[event]);
if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES)
&& (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)
|| (next_state == NSM_Full) || (next_state < nbr->state)))
- zlog_notice("AdjChg: Nbr %s on %s: %s -> %s (%s)",
- inet_ntoa(nbr->router_id), IF_NAME(nbr->oi),
+ zlog_notice("AdjChg: Nbr %s(%s) on %s: %s -> %s (%s)",
+ inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf), IF_NAME(nbr->oi),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
lookup_msg(ospf_nsm_state_msg, next_state, NULL),
ospf_nsm_event_str[event]);
if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
zlog_info(
- "%s:(%s, %s -> %s): "
+ "%s:[%s:%s], %s -> %s): "
"scheduling new router-LSA origination",
__PRETTY_FUNCTION__, inet_ntoa(nbr->router_id),
+ ospf_get_name(oi->ospf),
lookup_msg(ospf_nsm_state_msg, old_state, NULL),
lookup_msg(ospf_nsm_state_msg, state, NULL));
event = THREAD_VAL(thread);
if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
- zlog_debug("NSM[%s:%s]: %s (%s)", IF_NAME(nbr->oi),
+ zlog_debug("NSM[%s:%s:%s]: %s (%s)", IF_NAME(nbr->oi),
inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
ospf_nsm_event_str[event]);
*/
flog_err(
EC_OSPF_FSM_INVALID_STATE,
- "NSM[%s:%s]: %s (%s): "
+ "NSM[%s:%s:%s]: %s (%s): "
"Warning: action tried to change next_state to %s",
IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
+ ospf_get_name(nbr->oi->ospf),
lookup_msg(ospf_nsm_state_msg, nbr->state,
NULL),
ospf_nsm_event_str[event],
"ospf_write_frags: sent id %d, off %d, len %d to %s\n",
iph->ip_id, iph->ip_off, iph->ip_len,
inet_ntoa(iph->ip_dst));
- if (IS_DEBUG_OSPF_PACKET(type - 1, DETAIL)) {
- zlog_debug(
- "-----------------IP Header Dump----------------------");
- ospf_ip_header_dump(iph);
- zlog_debug(
- "-----------------------------------------------------");
- }
}
iph->ip_off += offset;
if (IS_DEBUG_OSPF_PACKET(type - 1, DETAIL)) {
zlog_debug(
"-----------------------------------------------------");
- ospf_ip_header_dump(&iph);
stream_set_getp(op->s, 0);
ospf_packet_dump(op->s);
}
/* Check DD Options. */
if (dd->options != nbr->options) {
-#ifdef ORIGINAL_CODING
- /* Save the new options for debugging */
- nbr->options = dd->options;
-#endif /* ORIGINAL_CODING */
flog_warn(EC_OSPF_PACKET,
"Packet[DD]: Neighbor %s options mismatch.",
inet_ntoa(nbr->router_id));
msgh.msg_control = (caddr_t)buff;
msgh.msg_controllen = sizeof(buff);
- ret = stream_recvmsg(ibuf, fd, &msgh, 0, OSPF_MAX_PACKET_SIZE + 1);
+ ret = stream_recvmsg(ibuf, fd, &msgh, MSG_DONTWAIT,
+ OSPF_MAX_PACKET_SIZE + 1);
if (ret < 0) {
- flog_warn(EC_OSPF_PACKET, "stream_recvmsg failed: %s",
- safe_strerror(errno));
+ if (errno != EAGAIN && errno != EWOULDBLOCK)
+ flog_warn(EC_OSPF_PACKET, "stream_recvmsg failed: %s",
+ safe_strerror(errno));
return NULL;
}
if ((unsigned int)ret < sizeof(iph)) /* ret must be > 0 now */
return NULL;
}
+ if (IS_DEBUG_OSPF_PACKET(0, RECV))
+ zlog_debug("%s: fd %d(%s) on interface %d(%s)",
+ __PRETTY_FUNCTION__, fd, ospf_get_name(ospf),
+ ifindex, *ifp ? (*ifp)->name : "Unknown");
return ibuf;
}
return 0;
}
-/* Starting point of packet process function. */
-int ospf_read(struct thread *thread)
+enum ospf_read_return_enum {
+ OSPF_READ_ERROR,
+ OSPF_READ_CONTINUE,
+};
+
+static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf)
{
int ret;
struct stream *ibuf;
- struct ospf *ospf;
struct ospf_interface *oi;
struct ip *iph;
struct ospf_header *ospfh;
uint16_t length;
- struct interface *ifp = NULL;
struct connected *c;
-
- /* first of all get interface pointer. */
- ospf = THREAD_ARG(thread);
-
- /* prepare for next packet. */
- ospf->t_read = NULL;
- thread_add_read(master, ospf_read, ospf, ospf->fd, &ospf->t_read);
+ struct interface *ifp = NULL;
stream_reset(ospf->ibuf);
ibuf = ospf_recv_packet(ospf, ospf->fd, &ifp, ospf->ibuf);
if (ibuf == NULL)
- return -1;
- /* This raw packet is known to be at least as big as its IP header. */
+ return OSPF_READ_ERROR;
- /* Note that there should not be alignment problems with this assignment
- because this is at the beginning of the stream data buffer. */
+ /*
+ * This raw packet is known to be at least as big as its
+ * IP header. Note that there should not be alignment problems with
+ * this assignment because this is at the beginning of the
+ * stream data buffer.
+ */
iph = (struct ip *)STREAM_DATA(ibuf);
- /* Note that sockopt_iphdrincl_swab_systoh was called in
- * ospf_recv_packet. */
-
+ /*
+ * Note that sockopt_iphdrincl_swab_systoh was called in
+ * ospf_recv_packet.
+ */
if (ifp == NULL) {
- /* Handle cases where the platform does not support retrieving
- the ifindex,
- and also platforms (such as Solaris 8) that claim to support
- ifindex
- retrieval but do not. */
+ /*
+ * Handle cases where the platform does not support
+ * retrieving the ifindex, and also platforms (such as
+ * Solaris 8) that claim to support ifindex retrieval but do
+ * not.
+ */
c = if_lookup_address((void *)&iph->ip_src, AF_INET,
ospf->vrf_id);
if (c)
ifp = c->ifp;
- if (ifp == NULL)
- return 0;
+ if (ifp == NULL) {
+ if (IS_DEBUG_OSPF_PACKET(0, RECV))
+ zlog_debug(
+ "%s: Unable to determine incoming interface from: %s(%s)",
+ __PRETTY_FUNCTION__,
+ inet_ntoa(iph->ip_src),
+ ospf_get_name(ospf));
+ return OSPF_READ_CONTINUE;
+ }
}
- /* IP Header dump. */
- if (IS_DEBUG_OSPF_PACKET(0, RECV))
- ospf_ip_header_dump(iph);
-
/* Self-originated packet should be discarded silently. */
if (ospf_if_lookup_by_local_addr(ospf, NULL, iph->ip_src)) {
if (IS_DEBUG_OSPF_PACKET(0, RECV)) {
"ospf_read[%s]: Dropping self-originated packet",
inet_ntoa(iph->ip_src));
}
- return 0;
+ return OSPF_READ_CONTINUE;
}
- /* Advance from IP header to OSPF header (iph->ip_hl has been verified
- by ospf_recv_packet() to be correct). */
+ /*
+ * Advance from IP header to OSPF header (iph->ip_hl has
+ * been verified by ospf_recv_packet() to be correct).
+ */
stream_forward_getp(ibuf, iph->ip_hl * 4);
ospfh = (struct ospf_header *)stream_pnt(ibuf);
if (MSG_OK
- != ospf_packet_examin(
- ospfh, stream_get_endp(ibuf) - stream_get_getp(ibuf)))
- return -1;
+ != ospf_packet_examin(ospfh, stream_get_endp(ibuf)
+ - stream_get_getp(ibuf)))
+ return OSPF_READ_CONTINUE;
/* Now it is safe to access all fields of OSPF packet header. */
/* associate packet with ospf interface */
oi = ospf_if_lookup_recv_if(ospf, iph->ip_src, ifp);
- /* ospf_verify_header() relies on a valid "oi" and thus can be called
- only
- after the passive/backbone/other checks below are passed. These
- checks
- in turn access the fields of unverified "ospfh" structure for their
- own
- purposes and must remain very accurate in doing this. */
+ /*
+ * ospf_verify_header() relies on a valid "oi" and thus can be called
+ * only after the passive/backbone/other checks below are passed.
+ * These checks in turn access the fields of unverified "ospfh"
+ * structure for their own purposes and must remain very accurate
+ * in doing this.
+ */
/* If incoming interface is passive one, ignore it. */
if (oi && OSPF_IF_PASSIVE_STATUS(oi) == OSPF_IF_PASSIVE) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ignoring packet from router %s sent to %s, "
- "received on a passive interface, %s",
+ "ignoring packet from router %s sent to %s, received on a passive interface, %s",
inet_ntop(AF_INET, &ospfh->router_id, buf[0],
sizeof(buf[0])),
inet_ntop(AF_INET, &iph->ip_dst, buf[1],
OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS);
ospf_if_set_multicast(oi);
}
- return 0;
+ return OSPF_READ_CONTINUE;
}
* or header area is backbone but ospf_interface is not
* check for VLINK interface
*/
- if ((oi == NULL) || (OSPF_IS_AREA_ID_BACKBONE(ospfh->area_id)
- && !OSPF_IS_AREA_ID_BACKBONE(oi->area->area_id))) {
+ if ((oi == NULL)
+ || (OSPF_IS_AREA_ID_BACKBONE(ospfh->area_id)
+ && !OSPF_IS_AREA_ID_BACKBONE(oi->area->area_id))) {
if ((oi = ospf_associate_packet_vl(ospf, ifp, iph, ospfh))
== NULL) {
if (!ospf->instance && IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "Packet from [%s] received on link %s"
- " but no ospf_interface",
+ "Packet from [%s] received on link %s but no ospf_interface",
inet_ntoa(iph->ip_src), ifp->name);
- return 0;
+ return OSPF_READ_CONTINUE;
}
}
- /* else it must be a local ospf interface, check it was received on
- * correct link
+ /*
+ * else it must be a local ospf interface, check it was
+ * received on correct link
*/
else if (oi->ifp != ifp) {
if (IS_DEBUG_OSPF_EVENT)
flog_warn(EC_OSPF_PACKET,
"Packet from [%s] received on wrong link %s",
inet_ntoa(iph->ip_src), ifp->name);
- return 0;
+ return OSPF_READ_CONTINUE;
} else if (oi->state == ISM_Down) {
char buf[2][INET_ADDRSTRLEN];
+
flog_warn(
EC_OSPF_PACKET,
- "Ignoring packet from %s to %s received on interface that is "
- "down [%s]; interface flags are %s",
+ "Ignoring packet from %s to %s received on interface that is down [%s]; interface flags are %s",
inet_ntop(AF_INET, &iph->ip_src, buf[0],
sizeof(buf[0])),
inet_ntop(AF_INET, &iph->ip_dst, buf[1],
OI_MEMBER_JOINED(oi, MEMBER_DROUTERS);
if (oi->multicast_memberships)
ospf_if_set_multicast(oi);
- return 0;
+ return OSPF_READ_CONTINUE;
}
/*
- * If the received packet is destined for AllDRouters, the packet
- * should be accepted only if the received ospf interface state is
- * either DR or Backup -- endo.
+ * If the received packet is destined for AllDRouters, the
+ * packet should be accepted only if the received ospf
+ * interface state is either DR or Backup -- endo.
+ *
+ * I wonder who endo is?
*/
if (iph->ip_dst.s_addr == htonl(OSPF_ALLDROUTERS)
&& (oi->state != ISM_DR && oi->state != ISM_Backup)) {
/* Try to fix multicast membership. */
SET_FLAG(oi->multicast_memberships, MEMBER_DROUTERS);
ospf_if_set_multicast(oi);
- return 0;
+ return OSPF_READ_CONTINUE;
}
/* Verify more OSPF header fields. */
"ospf_read[%s]: Header check failed, "
"dropping.",
inet_ntoa(iph->ip_src));
- return ret;
+ return OSPF_READ_CONTINUE;
}
/* Show debug receiving packet. */
/* Adjust size to message length. */
length = ntohs(ospfh->length) - OSPF_HEADER_SIZE;
- /* Read rest of the packet and call each sort of packet routine. */
+ /* Read rest of the packet and call each sort of packet routine.
+ */
switch (ospfh->type) {
case OSPF_MSG_HELLO:
ospf_hello(iph, ospfh, ibuf, oi, length);
ospf_ls_ack(iph, ospfh, ibuf, oi, length);
break;
default:
- flog_warn(EC_OSPF_PACKET,
- "interface %s: OSPF packet header type %d is illegal",
- IF_NAME(oi), ospfh->type);
+ flog_warn(
+ EC_OSPF_PACKET,
+ "interface %s(%s): OSPF packet header type %d is illegal",
+ IF_NAME(oi), ospf_get_name(ospf), ospfh->type);
break;
}
+ return OSPF_READ_CONTINUE;
+}
+
+/* Starting point of packet process function. */
+int ospf_read(struct thread *thread)
+{
+ struct ospf *ospf;
+ int32_t count = 0;
+ enum ospf_read_return_enum ret;
+
+ /* first of all get interface pointer. */
+ ospf = THREAD_ARG(thread);
+
+ /* prepare for next packet. */
+ thread_add_read(master, ospf_read, ospf, ospf->fd, &ospf->t_read);
+
+ while (count < ospf->write_oi_count) {
+ count++;
+ ret = ospf_read_helper(ospf);
+ switch (ret) {
+ case OSPF_READ_ERROR:
+ return -1;
+ break;
+ case OSPF_READ_CONTINUE:
+ break;
+ }
+ }
+
return 0;
}
return vrf ? vrf->name : "NIL";
}
+
+const char *ospf_get_name(const struct ospf *ospf)
+{
+ if (ospf->name)
+ return ospf->name;
+ else
+ return VRF_DEFAULT_NAME;
+}
const char *ospf_vrf_id_to_name(vrf_id_t vrf_id);
int ospf_area_nssa_no_summary_set(struct ospf *, struct in_addr);
+const char *ospf_get_name(const struct ospf *ospf);
#endif /* _ZEBRA_OSPFD_H */
int ins_count = 0;
while (buflen > offset) {
+ if (offset + (int)sizeof(struct bsmmsg_grpinfo) > buflen) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug(
+ "%s: buflen received %d is less than the internal data structure of the packet would suggest",
+ __PRETTY_FUNCTION__, buflen);
+ return false;
+ }
/* Extract Group tlv from BSM */
memcpy(&grpinfo, buf, sizeof(struct bsmmsg_grpinfo));
}
group.family = AF_INET;
+ if (grpinfo.group.mask > IPV4_MAX_BITLEN) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug("%s, v4 prefix length specified: %d is too long",
+ __PRETTY_FUNCTION__, grpinfo.group.mask);
+ return false;
+ }
group.prefixlen = grpinfo.group.mask;
group.u.prefix4.s_addr = grpinfo.group.addr.s_addr;
ins_count = 0;
while (frag_rp_cnt--) {
+ if (offset + (int)sizeof(struct bsmmsg_rpinfo)
+ > buflen) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug(
+ "%s, buflen received: %u is less than the internal data structure of the packet would suggest",
+ __PRETTY_FUNCTION__, buflen);
+ return false;
+ }
+
/* Extract RP address tlv from BSM */
memcpy(&rpinfo, buf, sizeof(struct bsmmsg_rpinfo));
rpinfo.rp_holdtime = ntohs(rpinfo.rp_holdtime);
return -1;
}
+ if (buf_size < (PIM_MSG_HEADER_LEN + sizeof(struct bsm_hdr))) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug("%s: received buffer length of %d which is too small to properly decode",
+ __PRETTY_FUNCTION__, buf_size);
+ return -1;
+ }
+
bshdr = (struct bsm_hdr *)(buf + PIM_MSG_HEADER_LEN);
pim_inet4_dump("<bsr?>", bshdr->bsr_addr.addr, bsr_str,
sizeof(bsr_str));
&& (source_flags & PIM_WILDCARD_BIT_MASK)) {
struct pim_rpf *rp = RP(pim_ifp->pim, sg->grp);
+ if (!rp) {
+ zlog_warn("%s: Lookup of RP failed for %pSG4",
+ __PRETTY_FUNCTION__, sg);
+ return;
+ }
/*
* If the RP sent in the message is not
* our RP for the group, drop the message
&& (source_flags & PIM_WILDCARD_BIT_MASK)) {
struct pim_rpf *rp = RP(pim_ifp->pim, sg->grp);
+ if (!rp) {
+ if (PIM_DEBUG_PIM_TRACE)
+ zlog_debug("%s: RP for %pSG4 completely failed lookup",
+ __PRETTY_FUNCTION__, sg);
+ return;
+ }
// Ignoring Prune *,G's at the moment.
if (sg->src.s_addr != rp->rpf_addr.u.prefix4.s_addr)
return;
no_fwd = header->Nbit;
if (header->type == PIM_MSG_TYPE_REGISTER) {
+ if (pim_msg_len < PIM_MSG_REGISTER_LEN) {
+ if (PIM_DEBUG_PIM_PACKETS)
+ zlog_debug("PIM Register Message size=%d shorther than min length %d",
+ pim_msg_len, PIM_MSG_REGISTER_LEN);
+ return -1;
+ }
/* First 8 byte header checksum */
checksum = in_cksum(pim_msg, PIM_MSG_REGISTER_LEN);
if (checksum != pim_checksum) {
rp_info = pim_rp_find_match_group(pim, &g);
- if ((pim_rpf_addr_is_inaddr_none(&rp_info->rp))
- && (source.s_addr == INADDR_ANY)) {
+ if (!rp_info || ((pim_rpf_addr_is_inaddr_none(&rp_info->rp))
+ && (source.s_addr == INADDR_ANY))) {
if (PIM_DEBUG_PIM_NHT_RP)
zlog_debug("%s: Received a (*,G) with no RP configured",
__PRETTY_FUNCTION__);
if (type) {
zlog_warn(
- "%s: unknown source address encoding type=%d: %02x%02x%02x%02x%02x%02x%02x%02x",
+ "%s: unknown source address encoding type=%d: %02x%02x%02x%02x",
__PRETTY_FUNCTION__, type, buf[0], buf[1], buf[2],
- buf[3], buf[4], buf[5], buf[6], buf[7]);
+ buf[3]);
return -2;
}
break;
default: {
zlog_warn(
- "%s: unknown source address encoding family=%d: %02x%02x%02x%02x%02x%02x%02x%02x",
+ "%s: unknown source address encoding family=%d: %02x%02x%02x%02x",
__PRETTY_FUNCTION__, family, buf[0], buf[1], buf[2],
- buf[3], buf[4], buf[5], buf[6], buf[7]);
+ buf[3]);
return -5;
}
}
install -D -m 0755 staticd-service $(DESTDIR)/bin/
install -D -m 0755 bfdd-service $(DESTDIR)/bin/
install -D -m 0755 fabricd-service $(DESTDIR)/bin/
+ install -D -m 0755 vrrpd-service $(DESTDIR)/bin/
install -D -m 0755 set-options $(DESTDIR)/bin/
install -D -m 0755 show_version $(DESTDIR)/bin/
--- /dev/null
+#!/bin/sh
+
+set -e -x
+
+if ! [ -e $SNAP_DATA/vrrpd.conf ]; then
+ cp $SNAP/etc/frr/vrrpd.conf.default $SNAP_DATA/vrrpd.conf
+fi
+exec $SNAP/sbin/vrrpd \
+ -f $SNAP_DATA/vrrpd.conf \
+ --pid_file $SNAP_DATA/vrrpd.pid \
+ --socket $SNAP_DATA/zsock \
+ --vty_socket $SNAP_DATA
+
- network
- network-bind
- network-control
+ vrrpd:
+ command: bin/vrrpd-service
+ daemon: simple
+ plugs:
+ - network
+ - network-bind
+ - network-control
set:
command: bin/set-options
zebra-debug:
- network
- network-bind
- network-control
-
+ vrrpd-debug:
+ command: sbin/vrrpd -f $SNAP_DATA/vrrpd.conf --pid_file $SNAP_DATA/vrrpd.pid --socket $SNAP_DATA/zsock --vty_socket $SNAP_DATA
+ plugs:
+ - network
+ - network-bind
+ - network-control
parts:
rtrlib:
build-packages:
- --enable-fpm
- --enable-protobuf
- --enable-rpki
+ - --enable-vrrpd
- --enable-configfile-mask=0640
- --enable-logfile-mask=0640
- --localstatedir=/var/run
pbrd.conf.default: etc/frr/pbrd.conf.default
bfdd.conf.default: etc/frr/bfdd.conf.default
fabricd.conf.default: etc/frr/fabricd.conf.default
+ vrrpd.conf.default: etc/frr/vrrpd.conf.default
vtysh.conf.default: etc/frr/vtysh.conf.default
staticd.conf.default: etc/frr/staticd.conf.default
frr-scripts:
self.lines = []
self.contexts = OrderedDict()
- def load_from_file(self, filename):
+ def load_from_file(self, filename, bindir, confdir):
"""
Read configuration from specified file and slurp it into internal memory
The internal representation has been marked appropriately by passing it
log.info('Loading Config object from file %s', filename)
try:
- file_output = subprocess.check_output(['/usr/bin/vtysh', '-m', '-f', filename],
+ file_output = subprocess.check_output([str(bindir + '/vtysh'), '-m', '-f', filename, '--config_dir', confdir],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
ve = VtyshMarkException(e)
self.load_contexts()
- def load_from_show_running(self):
+ def load_from_show_running(self, bindir, confdir, daemon):
"""
Read running configuration and slurp it into internal memory
The internal representation has been marked appropriately by passing it
try:
config_text = subprocess.check_output(
- "/usr/bin/vtysh -c 'show run' | /usr/bin/tail -n +4 | /usr/bin/vtysh -m -f -",
+ bindir + "/vtysh --config_dir " + confdir + " -c 'show run " + daemon + "' | /usr/bin/tail -n +4 | " + bindir + "/vtysh --config_dir " + confdir + " -m -f -",
shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
ve = VtyshMarkException(e)
"ip ",
"ipv6 ",
"log ",
- "mpls",
+ "mpls lsp",
+ "mpls label",
"no ",
"password ",
"ptm-enable",
continue
# one line contexts
- if new_ctx is True and any(line.startswith(keyword) for keyword in oneline_ctx_keywords):
+ # there is one exception though: ldpd accepts a 'router-id' clause
+ # as part of its 'mpls ldp' config context. If we are processing
+ # ldp configuration and encounter a router-id we should NOT switch
+ # to a new context
+ if new_ctx is True and any(line.startswith(keyword) for keyword in oneline_ctx_keywords) and not (
+ ctx_keys and ctx_keys[0].startswith("mpls ldp") and line.startswith("router-id ")):
self.save_contexts(ctx_keys, current_context_lines)
# Start a new context
current_context_lines = []
log.debug('LINE %-50s: popping from subcontext to ctx%-50s', line, ctx_keys)
- elif line == "exit-vni":
+ elif line in ["exit-vni", "exit-ldp-if"]:
if sub_main_ctx_key:
self.save_contexts(ctx_keys, current_context_lines)
elif (line.startswith("address-family ") or
line.startswith("vnc defaults") or
line.startswith("vnc l2-group") or
- line.startswith("vnc nve-group")):
+ line.startswith("vnc nve-group") or
+ line.startswith("member pseudowire")):
main_ctx_key = []
# Save old context first
main_ctx_key = copy.deepcopy(ctx_keys)
log.debug('LINE %-50s: entering sub-context, append to ctx_keys', line)
- if line == "address-family ipv6":
+ if line == "address-family ipv6" and not ctx_keys[0].startswith("mpls ldp"):
ctx_keys.append("address-family ipv6 unicast")
- elif line == "address-family ipv4":
+ elif line == "address-family ipv4" and not ctx_keys[0].startswith("mpls ldp"):
ctx_keys.append("address-family ipv4 unicast")
elif line == "address-family evpn":
ctx_keys.append("address-family l2vpn evpn")
sub_main_ctx_key = copy.deepcopy(ctx_keys)
log.debug('LINE %-50s: entering sub-sub-context, append to ctx_keys', line)
ctx_keys.append(line)
+
+ elif ((line.startswith("interface ") and
+ len(ctx_keys) == 2 and
+ ctx_keys[0].startswith('mpls ldp') and
+ ctx_keys[1].startswith('address-family'))):
+
+ # Save old context first
+ self.save_contexts(ctx_keys, current_context_lines)
+ current_context_lines = []
+ sub_main_ctx_key = copy.deepcopy(ctx_keys)
+ log.debug('LINE %-50s: entering sub-sub-context, append to ctx_keys', line)
+ ctx_keys.append(line)
else:
# Continuing in an existing context, add non-commented lines to it
self.save_contexts(ctx_keys, current_context_lines)
-def line_to_vtysh_conft(ctx_keys, line, delete):
+def line_to_vtysh_conft(ctx_keys, line, delete, bindir, confdir):
"""
Return the vtysh command for the specified context line
"""
cmd = []
- cmd.append('vtysh')
+ cmd.append(str(bindir + '/vtysh'))
+ cmd.append('--config_dir')
+ cmd.append(confdir)
cmd.append('-c')
cmd.append('conf t')
if re_nbr_bfd_timers:
nbr = re_nbr_bfd_timers.group(1)
bfd_nbr = "neighbor %s" % nbr
+ bfd_search_string = bfd_nbr + r' bfd (\S+) (\S+) (\S+)'
for (ctx_keys, add_line) in lines_to_add:
- re_add_nbr_bfd_timers = re.search(r'neighbor bfd_nbr bfd (\S+) (\S+) (\S+)', add_line)
+ re_add_nbr_bfd_timers = re.search(bfd_search_string, add_line)
if re_add_nbr_bfd_timers:
found_add_bfd_nbr = line_exist(lines_to_add, ctx_keys, bfd_nbr, False)
-def vtysh_config_available():
+def vtysh_config_available(bindir, confdir):
"""
Return False if no frr daemon is running or some other vtysh session is
in 'configuration terminal' mode which will prevent us from making any
"""
try:
- cmd = ['/usr/bin/vtysh', '-c', 'conf t']
+ cmd = [str(bindir + '/vtysh'), '--config_dir', confdir, '-c', 'conf t']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip()
if 'VTY configuration is locked by other VTY' in output.decode('utf-8'):
parser.add_argument('--stdout', action='store_true', help='Log to STDOUT', default=False)
parser.add_argument('filename', help='Location of new frr config file')
parser.add_argument('--overwrite', action='store_true', help='Overwrite frr.conf with running config output', default=False)
+ parser.add_argument('--bindir', help='path to the vtysh executable', default='/usr/bin')
+ parser.add_argument('--confdir', help='path to the daemon config files', default='/etc/frr')
+ parser.add_argument('--rundir', help='path for the temp config file', default='/var/run/frr')
+ parser.add_argument('--daemon', help='daemon for which want to replace the config', default='')
+
args = parser.parse_args()
# Logging
log.error(msg)
sys.exit(1)
+ # Verify that confdir is correct
+ if not os.path.isdir(args.confdir):
+ msg = "Confdir %s is not a valid path" % args.confdir
+ print(msg)
+ log.error(msg)
+ sys.exit(1)
+
+ # Verify that bindir is correct
+ if not os.path.isdir(args.bindir) or not os.path.isfile(args.bindir + '/vtysh'):
+ msg = "Bindir %s is not a valid path to vtysh" % args.bindir
+ print(msg)
+ log.error(msg)
+ sys.exit(1)
+
+ # verify that the daemon, if specified, is valid
+ if args.daemon and args.daemon not in ['zebra', 'bgpd', 'fabricd', 'isisd', 'ospf6d', 'ospfd', 'pbrd', 'pimd', 'ripd', 'ripngd', 'sharpd', 'staticd', 'vrrpd', 'ldpd']:
+ msg = "Daemon %s is not a valid option for 'show running-config'" % args.daemon
+ print(msg)
+ log.error(msg)
+ sys.exit(1)
+
# Verify that 'service integrated-vtysh-config' is configured
- vtysh_filename = '/etc/frr/vtysh.conf'
+ vtysh_filename = args.confdir + '/vtysh.conf'
service_integrated_vtysh_config = True
if os.path.isfile(vtysh_filename):
service_integrated_vtysh_config = False
break
- if not service_integrated_vtysh_config:
+ if not service_integrated_vtysh_config and not args.daemon:
msg = "'service integrated-vtysh-config' is not configured, this is required for 'service frr reload'"
print(msg)
log.error(msg)
# Create a Config object from the config generated by newconf
newconf = Config()
- newconf.load_from_file(args.filename)
+ newconf.load_from_file(args.filename, args.bindir, args.confdir)
reload_ok = True
if args.test:
running = Config()
if args.input:
- running.load_from_file(args.input)
+ running.load_from_file(args.input, args.bindir, args.confdir)
else:
- running.load_from_show_running()
+ running.load_from_show_running(args.bindir, args.confdir, args.daemon)
(lines_to_add, lines_to_del) = compare_context_objects(newconf, running)
lines_to_configure = []
elif args.reload:
# We will not be able to do anything, go ahead and exit(1)
- if not vtysh_config_available():
+ if not vtysh_config_available(args.bindir, args.confdir):
sys.exit(1)
log.debug('New Frr Config\n%s', newconf.get_lines())
for x in range(2):
running = Config()
- running.load_from_show_running()
+ running.load_from_show_running(args.bindir, args.confdir, args.daemon)
log.debug('Running Frr Config (Pass #%d)\n%s', x, running.get_lines())
(lines_to_add, lines_to_del) = compare_context_objects(newconf, running)
# 'no' commands are tricky, we can't just put them in a file and
# vtysh -f that file. See the next comment for an explanation
# of their quirks
- cmd = line_to_vtysh_conft(ctx_keys, line, True)
+ cmd = line_to_vtysh_conft(ctx_keys, line, True, args.bindir, args.confdir)
original_cmd = cmd
# Some commands in frr are picky about taking a "no" of the entire line.
string.ascii_uppercase +
string.digits) for _ in range(6))
- filename = "/var/run/frr/reload-%s.txt" % random_string
+ filename = args.rundir + "/reload-%s.txt" % random_string
log.info("%s content\n%s" % (filename, pformat(lines_to_configure)))
with open(filename, 'w') as fh:
fh.write(line + '\n')
try:
- subprocess.check_output(['/usr/bin/vtysh', '-f', filename], stderr=subprocess.STDOUT)
+ subprocess.check_output([str(args.bindir + '/vtysh'), '--config_dir', args.confdir, '-f', filename], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
log.warning("frr-reload.py failed due to\n%s" % e.output)
reload_ok = False
os.unlink(filename)
# Make these changes persistent
- if args.overwrite or args.filename != '/etc/frr/frr.conf':
- subprocess.call(['/usr/bin/vtysh', '-c', 'write'])
+ target = str(args.confdir + '/frr.conf')
+ if args.overwrite or (not args.daemon and args.filename != target):
+ subprocess.call([str(args.bindir + '/vtysh'), '--config_dir', args.confdir, '-c', 'write'])
if not reload_ok:
sys.exit(1)
switch (vty->node) {
case LDP_IPV4_IFACE_NODE:
if (strncmp(vty_buf_copy, " ", 3)) {
- vty_out(vty, " end\n");
+ vty_out(vty, " exit-ldp-if\n");
vty->node = LDP_IPV4_NODE;
}
break;
case LDP_IPV6_IFACE_NODE:
if (strncmp(vty_buf_copy, " ", 3)) {
- vty_out(vty, " end\n");
+ vty_out(vty, " exit-ldp-if\n");
vty->node = LDP_IPV6_NODE;
}
break;
case LDP_PSEUDOWIRE_NODE:
if (strncmp(vty_buf_copy, " ", 2)) {
- vty_out(vty, " end\n");
+ vty_out(vty, " exit\n");
vty->node = LDP_L2VPN_NODE;
}
break;
&rtadv->ra_timer);
break;
case RTADV_STOP:
- if (rtadv->ra_timer) {
- thread_cancel(rtadv->ra_timer);
- rtadv->ra_timer = NULL;
- }
- if (rtadv->ra_read) {
- thread_cancel(rtadv->ra_read);
- rtadv->ra_read = NULL;
- }
+ THREAD_OFF(rtadv->ra_timer);
+ THREAD_OFF(rtadv->ra_read);
break;
case RTADV_TIMER:
thread_add_timer(zrouter.master, rtadv_timer, zvrf, val,
if (vrf_is_backend_netns()) {
zvrf->rtadv.sock = rtadv_make_socket(zvrf->zns->ns_id);
zrouter.rtadv_sock = -1;
- } else if (!zrouter.rtadv_sock) {
+ } else {
zvrf->rtadv.sock = -1;
- if (!zrouter.rtadv_sock)
- zrouter.rtadv_sock = rtadv_make_socket(zvrf->zns->ns_id);
+ if (zrouter.rtadv_sock < 0)
+ zrouter.rtadv_sock =
+ rtadv_make_socket(zvrf->zns->ns_id);
}
}
zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS;
+ zrouter.rtadv_sock = -1;
+
zebra_vxlan_init();
zebra_mlag_init();