X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fflow.c;h=cb6b32cff6e09187b12e0f03a1febe0dad8ff084;hb=refs%2Fheads%2Ffor-nox%2F0.4;hp=ebe9050f0cdcbccdd07339825b60b38623b6df1b;hpb=06e22ff0fe709ec119fea34c555e9411a4cce0d9;p=sliver-openvswitch.git diff --git a/lib/flow.c b/lib/flow.c index ebe9050f0..cb6b32cff 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -38,7 +38,7 @@ #include #include "hash.h" #include "ofpbuf.h" -#include "openflow.h" +#include "openflow/openflow.h" #include "packets.h" #include "vlog.h" @@ -76,6 +76,12 @@ pull_udp(struct ofpbuf *packet) return ofpbuf_try_pull(packet, UDP_HEADER_LEN); } +static struct icmp_header * +pull_icmp(struct ofpbuf *packet) +{ + return ofpbuf_try_pull(packet, ICMP_HEADER_LEN); +} + static struct eth_header * pull_eth(struct ofpbuf *packet) { @@ -96,16 +102,6 @@ flow_extract(struct ofpbuf *packet, uint16_t in_port, struct flow *flow) 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 - * can end up with runt frames, e.g. frames that only ever passed - * through virtual network devices and never touched a physical - * Ethernet. */ - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 60); - VLOG_DBG_RL(&rl, "packet length %zu less than minimum size %d", - b.size, ETH_TOTAL_MIN); - } - memset(flow, 0, sizeof *flow); flow->dl_vlan = htons(OFP_VLAN_NONE); flow->in_port = htons(in_port); @@ -181,6 +177,17 @@ flow_extract(struct ofpbuf *packet, uint16_t in_port, struct flow *flow) * this packet has an L4 header. */ flow->nw_proto = 0; } + } else if (flow->nw_proto == IP_TYPE_ICMP) { + const struct icmp_header *icmp = pull_icmp(&b); + if (icmp) { + flow->icmp_type = htons(icmp->icmp_type); + flow->icmp_code = htons(icmp->icmp_code); + packet->l7 = b.data; + } else { + /* Avoid tricking other code into thinking that + * this packet has an L4 header. */ + flow->nw_proto = 0; + } } } else { retval = 1;