This patch adds IGMP support to flow_compose and
flow_extract.
Acked-by: Daniel Borkmann <[email protected]>
Acked-by: Thomas Graf <[email protected]>
Signed-off-by: Flavio Leitner <[email protected]>
---
lib/flow.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/flow.c b/lib/flow.c
index 83b926f..cdf1ae1 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -81,6 +81,12 @@ pull_icmpv6(struct ofpbuf *packet)
return ofpbuf_try_pull(packet, sizeof(struct icmp6_hdr));
}
+static struct igmp_header *
+pull_igmp(struct ofpbuf *packet)
+{
+ return ofpbuf_try_pull(packet, IGMP_HEADER_LEN);
+}
+
static void
parse_mpls(struct ofpbuf *b, struct flow *flow)
{
@@ -431,6 +437,13 @@ flow_extract(struct ofpbuf *packet, const struct
pkt_metadata *md,
flow->tp_src = htons(icmp->icmp_type);
flow->tp_dst = htons(icmp->icmp_code);
}
+ } else if (flow->nw_proto == IPPROTO_IGMP) {
+ const struct igmp_header *igmp = pull_igmp(&b);
+ if (igmp) {
+ flow->igmp_type = htons(igmp->igmp_type);
+ flow->igmp_code = htons(igmp->igmp_code);
+ flow->igmp_group.u.ip4 =
get_16aligned_be32(&igmp->group);
+ }
}
}
}
@@ -1276,6 +1289,14 @@ flow_compose_l4(struct ofpbuf *b, const struct flow
*flow)
icmp->icmp_type = ntohs(flow->tp_src);
icmp->icmp_code = ntohs(flow->tp_dst);
icmp->icmp_csum = csum(icmp, ICMP_HEADER_LEN);
+ } else if (flow->nw_proto == IPPROTO_IGMP) {
+ struct igmp_header *igmp;
+
+ igmp = ofpbuf_put_zeros(b, sizeof *igmp);
+ igmp->igmp_type = ntohs(flow->igmp_type);
+ igmp->igmp_code = ntohs(flow->igmp_code);
+ put_16aligned_be32(&igmp->group, flow->igmp_group.u.ip4);
+ igmp->igmp_csum = csum(igmp, IGMP_HEADER_LEN);
} else if (flow->nw_proto == IPPROTO_ICMPV6) {
struct icmp6_hdr *icmp;
--
1.9.0
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev