Implement OFPC_FRAG_DROP fragment handling policy.
[sliver-openvswitch.git] / lib / flow.c
index c8e647a..f534f57 100644 (file)
@@ -44,7 +44,7 @@
 #include "vlog.h"
 #define THIS_MODULE VLM_flow
 
-struct ip_header *
+static struct ip_header *
 pull_ip(struct buffer *packet)
 {
     if (packet->size >= IP_HEADER_LEN) {
@@ -57,7 +57,7 @@ pull_ip(struct buffer *packet)
     return NULL;
 }
 
-struct tcp_header *
+static struct tcp_header *
 pull_tcp(struct buffer *packet) 
 {
     if (packet->size >= TCP_HEADER_LEN) {
@@ -70,13 +70,13 @@ pull_tcp(struct buffer *packet)
     return NULL;
 }
 
-struct udp_header *
+static struct udp_header *
 pull_udp(struct buffer *packet) 
 {
     return buffer_try_pull(packet, UDP_HEADER_LEN);
 }
 
-struct eth_header *
+static struct eth_header *
 pull_eth(struct buffer *packet) 
 {
     return buffer_try_pull(packet, ETH_HEADER_LEN);
@@ -88,11 +88,13 @@ pull_vlan(struct buffer *packet)
     return buffer_try_pull(packet, VLAN_HEADER_LEN);
 }
 
-void
+/* Returns 1 if 'packet' is an IP fragment, 0 otherwise. */
+int
 flow_extract(struct buffer *packet, uint16_t in_port, struct flow *flow)
 {
     struct buffer b = *packet;
     struct eth_header *eth;
+    int retval = 0;
 
     if (b.size < ETH_TOTAL_MIN) {
         /* This message is not too useful since there are various ways that we
@@ -121,7 +123,7 @@ flow_extract(struct buffer *packet, uint16_t in_port, struct flow *flow)
             /* This is an 802.2 frame */
             struct llc_snap_header *h = buffer_at(&b, 0, sizeof *h);
             if (h == NULL) {
-                return;
+                return 0;
             }
             if (h->llc.llc_dsap == LLC_DSAP_SNAP
                 && h->llc.llc_ssap == LLC_SSAP_SNAP
@@ -179,10 +181,13 @@ flow_extract(struct buffer *packet, uint16_t in_port, struct flow *flow)
                             flow->nw_proto = 0;
                         }
                     }
+                } else {
+                    retval = 1;
                 }
             }
         }
     }
+    return retval;
 }
 
 void