]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: implement draft-ietf-isis-ext-eth and support p2p over LAN on BSD
authorChristian Franke <chris@opensourcerouting.org>
Thu, 27 Apr 2017 10:56:11 +0000 (12:56 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Fri, 28 Apr 2017 10:03:23 +0000 (12:03 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
isisd/isis_bpf.c
isisd/isis_constants.h
isisd/isis_pfpacket.c

index 3a5eaf558514fde56db242cfbf950d81d2f1804a..0a1610b6f207f62249ba0ad9a77cfb83f4551e82 100644 (file)
@@ -212,16 +212,11 @@ isis_sock_init (struct isis_circuit *circuit)
       goto end;
     }
 
-  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+  if (if_is_broadcast(circuit->interface))
     {
       circuit->tx = isis_send_pdu_bcast;
       circuit->rx = isis_recv_pdu_bcast;
     }
-  else if (circuit->circ_type == CIRCUIT_T_P2P)
-    {
-      circuit->tx = isis_send_pdu_p2p;
-      circuit->rx = isis_recv_pdu_p2p;
-    }
   else
     {
       zlog_warn ("isis_sock_init(): unknown circuit type");
@@ -283,23 +278,6 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
   return ISIS_OK;
 }
 
-int
-isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
-{
-  int bytesread;
-
-  bytesread = stream_read (circuit->rcv_stream, circuit->fd, 
-                           circuit->interface->mtu);
-
-  if (bytesread < 0)
-    {
-      zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", safe_strerror (errno));
-      return ISIS_WARNING;
-    }
-
-  return ISIS_OK;
-}
-
 int
 isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
 {
@@ -327,7 +305,8 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
   else
     memcpy (eth->ether_dhost, ALL_L2_ISS, ETHER_ADDR_LEN);
   memcpy (eth->ether_shost, circuit->u.bc.snpa, ETHER_ADDR_LEN);
-  eth->ether_type = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN);
+  size_t frame_size = stream_get_endp(circuit->snd_stream) + LLC_LEN;
+  eth->ether_type = htons(isis_ethertype(frame_size));
 
   /*
    * Then the LLC
@@ -354,10 +333,4 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
   return ISIS_OK;
 }
 
-int
-isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
-{
-  return ISIS_OK;
-}
-
 #endif /* ISIS_METHOD == ISIS_METHOD_BPF */
index 17616d671b55658aca033f7f1a72471b7fb00bf1..ec0f6fb62cfc14fe68999ee94d23f89b18cc66ac 100644 (file)
 #define ETH_ALEN 6
 #endif
 
+#define MAX_LLC_LEN 0x5ff
+#define ETHERTYPE_EXT_LLC 0x8870
+
+static inline uint16_t isis_ethertype(size_t len)
+{
+  if (len > MAX_LLC_LEN)
+    return ETHERTYPE_EXT_LLC;
+  return len;
+}
+
 #endif /* ISIS_CONSTANTS_H */
index dd07a9c6f5758758178ce6a4c43167f7d7c0f96c..5c434b90d1721c379332fa13f90011e222402cc5 100644 (file)
@@ -371,7 +371,9 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
   stream_set_getp (circuit->snd_stream, 0);
   memset (&sa, 0, sizeof (struct sockaddr_ll));
   sa.sll_family = AF_PACKET;
-  sa.sll_protocol = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN);
+
+  size_t frame_size = stream_get_endp(circuit->snd_stream) + LLC_LEN;
+  sa.sll_protocol = htons(isis_ethertype(frame_size));
   sa.sll_ifindex = circuit->interface->ifindex;
   sa.sll_halen = ETH_ALEN;
   /* RFC5309 section 4.1 recommends ALL_ISS */
@@ -418,7 +420,6 @@ isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
   stream_set_getp (circuit->snd_stream, 0);
   memset (&sa, 0, sizeof (struct sockaddr_ll));
   sa.sll_family = AF_PACKET;
-  sa.sll_protocol = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN);
   sa.sll_ifindex = circuit->interface->ifindex;
   sa.sll_halen = ETH_ALEN;
   if (level == 1)