def _validate_subnet_cidr(context, network_id, new_subnet_cidr):
if neutron_cfg.cfg.CONF.allow_overlapping_ips:<EOL><INDENT>return<EOL><DEDENT>try:<EOL><INDENT>new_subnet_ipset = netaddr.IPSet([new_subnet_cidr])<EOL><DEDENT>except TypeError:<EOL><INDENT>LOG.exception("<STR_LIT>" % new_subnet_cidr)<EOL>raise n_exc.BadRequest(resource="<STR_LIT>",<EOL>msg="<STR_LIT>")<EOL><DEDENT>filters = {<EOL>'<STR_LIT>': network_id,<EOL>'<STR_LIT>': [False]<EOL>}<EOL>subnet_list = db_api.subnet_find(context=context.elevated(), **filters)<EOL>for subnet in subnet_list:<EOL><INDENT>if (netaddr.IPSet([subnet.cidr]) & new_subnet_ipset):<EOL><INDENT>err_msg = (_("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>") %<EOL>{'<STR_LIT>': new_subnet_cidr,<EOL>'<STR_LIT>': network_id})<EOL>LOG.error(_("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"),<EOL>{'<STR_LIT>': new_subnet_cidr,<EOL>'<STR_LIT>': subnet.id,<EOL>'<STR_LIT>': subnet.cidr})<EOL>raise n_exc.InvalidInput(error_message=err_msg)<EOL><DEDENT><DEDENT>
Validate the CIDR for a subnet.

    Verifies the specified CIDR does not overlap with the ones defined
    for the other subnets specified for this network, or with any other
    CIDR if overlapping IPs are disabled.