netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / lib / rstp.h
index ccf8292..4942d59 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2014 M3S, Srl - Italy
+ * Copyright (c) 2011-2015 M3S, Srl - Italy
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
  * Authors:
  *         Martino Fornasa <mf@fornasa.it>
  *         Daniele Venturino <daniele.venturino@m3s.it>
+ *         Carlo Andreotti <c.andreotti@m3s.it>
  *
  * References to IEEE 802.1D-2004 standard are enclosed in square brackets.
  * E.g. [17.3], [Table 17-1], etc.
@@ -43,7 +44,7 @@ extern struct ovs_mutex rstp_mutex;
 
 #define RSTP_MAX_PORTS 4095
 
-struct ofpbuf;
+struct dp_packet;
 
 /* Bridge priority defaults [Table 17-2] */
 #define RSTP_MIN_PRIORITY 0
@@ -120,6 +121,12 @@ enum rstp_port_role {
     ROLE_DISABLED
 };
 
+enum rstp_admin_point_to_point_mac_state {
+    RSTP_ADMIN_P2P_MAC_FORCE_FALSE,
+    RSTP_ADMIN_P2P_MAC_FORCE_TRUE,
+    RSTP_ADMIN_P2P_MAC_AUTO
+};
+
 struct rstp;
 struct rstp_port;
 struct ofproto_rstp_settings;
@@ -134,7 +141,7 @@ void rstp_init(void)
     OVS_EXCLUDED(rstp_mutex);
 
 struct rstp * rstp_create(const char *, rstp_identifier bridge_id,
-                          void (*send_bpdu)(struct ofpbuf *, void *port_aux,
+                          void (*send_bpdu)(struct dp_packet *, void *port_aux,
                                             void *rstp_aux),
                           void *aux)
     OVS_EXCLUDED(rstp_mutex);
@@ -151,13 +158,21 @@ void rstp_tick_timers(struct rstp *)
 void rstp_port_received_bpdu(struct rstp_port *, const void *bpdu,
                              size_t bpdu_size)
     OVS_EXCLUDED(rstp_mutex);
-bool rstp_check_and_reset_fdb_flush(struct rstp *)
+void *rstp_check_and_reset_fdb_flush(struct rstp *, struct rstp_port **)
     OVS_EXCLUDED(rstp_mutex);
 void *rstp_get_next_changed_port_aux(struct rstp *, struct rstp_port **)
     OVS_EXCLUDED(rstp_mutex);
 void rstp_port_set_mac_operational(struct rstp_port *,
                                    bool new_mac_operational)
     OVS_EXCLUDED(rstp_mutex);
+bool rstp_shift_root_learned_address(struct rstp *)
+    OVS_EXCLUDED(rstp_mutex);
+void *rstp_get_old_root_aux(struct rstp *)
+    OVS_EXCLUDED(rstp_mutex);
+void *rstp_get_new_root_aux(struct rstp *)
+    OVS_EXCLUDED(rstp_mutex);
+void rstp_reset_root_changed(struct rstp *)
+    OVS_EXCLUDED(rstp_mutex);
 
 /* Bridge setters */
 void rstp_set_bridge_address(struct rstp *, rstp_identifier bridge_address)
@@ -211,7 +226,8 @@ uint32_t rstp_convert_speed_to_cost(unsigned int speed);
 
 void rstp_port_set(struct rstp_port *, uint16_t port_num, int priority,
                    uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
-                   bool do_mcheck, void *aux)
+                   enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state,
+                   bool admin_port_state, bool do_mcheck, void *aux)
     OVS_EXCLUDED(rstp_mutex);
 
 enum rstp_state rstp_port_get_state(const struct rstp_port *)
@@ -225,8 +241,8 @@ void rstp_port_get_status(const struct rstp_port *, uint16_t *id,
                           int *rx_count, int *error_count, int *uptime)
     OVS_EXCLUDED(rstp_mutex);
 
-void * rstp_get_port_aux(struct rstp *rstp, uint16_t port_number)
-    OVS_EXCLUDED(rstp_mutex);
+void * rstp_get_port_aux__(struct rstp *rstp, uint16_t port_number)
+    OVS_REQUIRES(rstp_mutex);
 
 \f
 /* Internal API for rstp-state-machines.c */
@@ -267,26 +283,20 @@ rstp_should_manage_bpdu(enum rstp_state state)
 
 /* Returns true if 'state' is one in which packets received on a port should
  * be forwarded, false otherwise.
- *
- * Returns true if 'state' is RSTP_DISABLED, since presumably in that case the
- * port should still work, just not have RSTP applied to it.
  */
 static inline bool
 rstp_forward_in_state(enum rstp_state state)
 {
-    return (state == RSTP_DISABLED || state == RSTP_FORWARDING);
+    return (state == RSTP_FORWARDING);
 }
 
 /* Returns true if 'state' is one in which MAC learning should be done on
  * packets received on a port, false otherwise.
- *
- * Returns true if 'state' is RSTP_DISABLED, since presumably in that case the
- * port should still work, just not have RSTP applied to it. */
+ */
 static inline bool
 rstp_learn_in_state(enum rstp_state state)
 {
-    return (state == RSTP_DISABLED || state == RSTP_LEARNING ||
-            state == RSTP_FORWARDING);
+    return (state == RSTP_LEARNING || state == RSTP_FORWARDING);
 }
 
 #endif /* rstp.h */