]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/rtadv.c
zebra: On shutdown stop hook calls for fpm rmac updates
[mirror_frr.git] / zebra / rtadv.c
index a8ec60844cdaf5fc340caf3053cc79474caba17a..9af41cbc393ab824a115158dc94fffd0bb099647 100644 (file)
@@ -1,30 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* Router advertisement
  * Copyright (C) 2016 Cumulus Networks
  * Copyright (C) 2005 6WIND <jean-mickael.guerin@6wind.com>
  * Copyright (C) 1999 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
 
 #include "memory.h"
 #include "sockopt.h"
-#include "thread.h"
+#include "frrevent.h"
 #include "if.h"
 #include "stream.h"
 #include "log.h"
@@ -490,9 +475,9 @@ no_more_opts:
                zif->ra_sent++;
 }
 
-static void rtadv_timer(struct thread *thread)
+static void rtadv_timer(struct event *thread)
 {
-       struct zebra_vrf *zvrf = THREAD_ARG(thread);
+       struct zebra_vrf *zvrf = EVENT_ARG(thread);
        struct vrf *vrf;
        struct interface *ifp;
        struct zebra_if *zif;
@@ -585,6 +570,28 @@ static void rtadv_process_solicit(struct interface *ifp)
                zif->rtadv.AdvIntervalTimer = MIN_DELAY_BETWEEN_RAS;
 }
 
+static const char *rtadv_optionalhdr2str(uint8_t opt_type)
+{
+       switch (opt_type) {
+       case ND_OPT_SOURCE_LINKADDR:
+               return "Optional Source Link Address";
+       case ND_OPT_TARGET_LINKADDR:
+               return "Optional Target Link Address";
+       case ND_OPT_PREFIX_INFORMATION:
+               return "Optional Prefix Information";
+       case ND_OPT_REDIRECTED_HEADER:
+               return "Optional Redirected Header";
+       case ND_OPT_MTU:
+               return "Optional MTU";
+       case ND_OPT_RTR_ADV_INTERVAL:
+               return "Optional Advertisement Interval";
+       case ND_OPT_HOME_AGENT_INFO:
+               return "Optional Home Agent Information";
+       }
+
+       return "Unknown Optional Type";
+}
+
 /*
  * This function processes optional attributes off of
  * end of a RA packet received.  At this point in
@@ -609,6 +616,13 @@ static void rtadv_process_optional(uint8_t *optional, unsigned int len,
                                                          &addr->sin6_addr, 1);
                        break;
                default:
+                       if (IS_ZEBRA_DEBUG_PACKET)
+                               zlog_debug(
+                                       "%s:Received Packet with optional Header type %s(%u) that is being ignored",
+                                       __func__,
+                                       rtadv_optionalhdr2str(
+                                               opt_hdr->nd_opt_type),
+                                       opt_hdr->nd_opt_type);
                        break;
                }
 
@@ -803,7 +817,7 @@ static void rtadv_process_packet(uint8_t *buf, unsigned int len,
        return;
 }
 
-static void rtadv_read(struct thread *thread)
+static void rtadv_read(struct event *thread)
 {
        int sock;
        int len;
@@ -811,9 +825,9 @@ static void rtadv_read(struct thread *thread)
        struct sockaddr_in6 from;
        ifindex_t ifindex = 0;
        int hoplimit = -1;
-       struct zebra_vrf *zvrf = THREAD_ARG(thread);
+       struct zebra_vrf *zvrf = EVENT_ARG(thread);
 
-       sock = THREAD_FD(thread);
+       sock = EVENT_FD(thread);
        zvrf->rtadv.ra_read = NULL;
 
        /* Register myself. */
@@ -2786,26 +2800,26 @@ static void rtadv_event(struct zebra_vrf *zvrf, enum rtadv_event event, int val)
 
        switch (event) {
        case RTADV_START:
-               thread_add_read(zrouter.master, rtadv_read, zvrf, rtadv->sock,
-                               &rtadv->ra_read);
-               thread_add_event(zrouter.master, rtadv_timer, zvrf, 0,
-                                &rtadv->ra_timer);
+               event_add_read(zrouter.master, rtadv_read, zvrf, rtadv->sock,
+                              &rtadv->ra_read);
+               event_add_event(zrouter.master, rtadv_timer, zvrf, 0,
+                               &rtadv->ra_timer);
                break;
        case RTADV_STOP:
-               THREAD_OFF(rtadv->ra_timer);
-               THREAD_OFF(rtadv->ra_read);
+               EVENT_OFF(rtadv->ra_timer);
+               EVENT_OFF(rtadv->ra_read);
                break;
        case RTADV_TIMER:
-               thread_add_timer(zrouter.master, rtadv_timer, zvrf, val,
-                                &rtadv->ra_timer);
+               event_add_timer(zrouter.master, rtadv_timer, zvrf, val,
+                               &rtadv->ra_timer);
                break;
        case RTADV_TIMER_MSEC:
-               thread_add_timer_msec(zrouter.master, rtadv_timer, zvrf, val,
-                                     &rtadv->ra_timer);
+               event_add_timer_msec(zrouter.master, rtadv_timer, zvrf, val,
+                                    &rtadv->ra_timer);
                break;
        case RTADV_READ:
-               thread_add_read(zrouter.master, rtadv_read, zvrf, rtadv->sock,
-                               &rtadv->ra_read);
+               event_add_read(zrouter.master, rtadv_read, zvrf, rtadv->sock,
+                              &rtadv->ra_read);
                break;
        default:
                break;