[libvirt] [PATCH V13 2/5] nwfilter: add DHCP snooping

Stefan Berger stefanb at linux.vnet.ibm.com
Fri Apr 27 15:41:41 UTC 2012


On 04/25/2012 08:59 AM, Stefan Berger wrote:
> +
> +/*
> + * Create a new Snoop request. Initialize it with the given
> + * interface key. The caller must release the request with a call
> + * to virNWFilerSnoopReqPut(req).
> + */
> +static virNWFilterSnoopReqPtr
> +virNWFilterSnoopReqNew(const char *ifkey)
> +{
> +    virNWFilterSnoopReqPtr req;
> +
> +    if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) {
> +        virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
> +                               _("virNWFilterSnoopReqNew called with invalid "
> +                                 "key \"%s\" (%u)"),
> +                               ifkey ? ifkey : "",
> +                               (unsigned int)strlen(ifkey));
> +        return NULL;
> +    }
> +
> +    if (VIR_ALLOC(req)<  0) {
> +        virReportOOMError();
> +        return NULL;
> +    }
> +
> +    virNWFilterSnoopReqGet(req);

In case someone wanted to try this out, the above line must be removed...

> +
> +    req->threadStatus = THREAD_STATUS_NONE;
> +
> +    if (virAtomicIntInit(&req->refctr)<  0 ||
> +        virMutexInitRecursive(&req->lock)<  0 ||
> +        virStrcpyStatic(req->ifkey, ifkey) == NULL ||
> +        virCondInit(&req->threadStatusCond)<  0)
> +        VIR_FREE(req);
> +

...and the following inserted here.

     if (req)
         virNWFilterSnoopReqGet(req);


    Stefan




More information about the libvir-list mailing list