2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

packets: Add IGMPv3 query packet definitions

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Dumitru Ceara
2019-07-15 22:24:37 +02:00
committed by Ben Pfaff
parent 6778f245f6
commit 1db4445395
2 changed files with 62 additions and 1 deletions

View File

@@ -1281,6 +1281,50 @@ packet_set_icmp(struct dp_packet *packet, uint8_t type, uint8_t code)
}
}
/* Sets the IGMP type to IGMP_HOST_MEMBERSHIP_QUERY and populates the
* v3 query header fields in 'packet'. 'packet' must be a valid IGMPv3
* query packet with its l4 offset properly populated.
*/
void
packet_set_igmp3_query(struct dp_packet *packet, uint8_t max_resp,
ovs_be32 group, bool srs, uint8_t qrv, uint8_t qqic)
{
struct igmpv3_query_header *igh = dp_packet_l4(packet);
ovs_be16 orig_type_max_resp =
htons(igh->type << 8 | igh->max_resp);
ovs_be16 new_type_max_resp =
htons(IGMP_HOST_MEMBERSHIP_QUERY << 8 | max_resp);
if (orig_type_max_resp != new_type_max_resp) {
igh->type = IGMP_HOST_MEMBERSHIP_QUERY;
igh->max_resp = max_resp;
igh->csum = recalc_csum16(igh->csum, orig_type_max_resp,
new_type_max_resp);
}
ovs_be32 old_group = get_16aligned_be32(&igh->group);
if (old_group != group) {
put_16aligned_be32(&igh->group, group);
igh->csum = recalc_csum32(igh->csum, old_group, group);
}
/* See RFC 3376 4.1.6. */
if (qrv > 7) {
qrv = 0;
}
ovs_be16 orig_srs_qrv_qqic = htons(igh->srs_qrv << 8 | igh->qqic);
ovs_be16 new_srs_qrv_qqic = htons(srs << 11 | qrv << 8 | qqic);
if (orig_srs_qrv_qqic != new_srs_qrv_qqic) {
igh->srs_qrv = (srs << 3 | qrv);
igh->qqic = qqic;
igh->csum = recalc_csum16(igh->csum, orig_srs_qrv_qqic,
new_srs_qrv_qqic);
}
}
void
packet_set_nd_ext(struct dp_packet *packet, const ovs_16aligned_be32 rso_flags,
const uint8_t opt_type)