~serge-hallyn/ubuntu/raring/libvirt/libvirt-hugepages

« back to all changes in this revision

Viewing changes to src/nwfilter/nwfilter_learnipaddr.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-13 15:44:12 UTC
  • mfrom: (1.2.13)
  • Revision ID: package-import@ubuntu.com-20120513154412-fgmn5sxqdzgnzlx3
Tags: 0.9.12-0ubuntu1
* New upstream version:
  * Synchronize with debian packaging:
    - debian/control: Update build depends.
    - debian/libvirt-bin.postrm: Cleanup /var/log/libvirt
      on purge.
    - Bump standards verson (no changes).
    - debian/patches/Don-t-fail-if-we-can-t-setup-avahi.patch: Added
  * Dropped patches:
    - debian/patches/Debianize-libvirt-guests.patch
    - debian/patches/rewrite-lxc-controller-eof-handling-yet-again
    - debian/patches/ubuntu/libnl13.patch
    - debian/patches/ubuntu/fix-lxc-startup-error.patch
    - debian/patches/ubuntu/fix-bridge-fd.patch
    - debian/patches/ubuntu/skip-labelling-network-disks.patch
    - debian/patches/ubuntu/xen-xend-shutdown-detection.patch
    - debian/patches/ubuntu/xen-config-no-vfb-for-hvm.patch
    - debian/patches/debian/Disable-daemon-start-test.patch
    - debian/patches/debian/Disable-gnulib-s-test-nonplocking-pipe.sh.patch
    - debian/patches/ubuntu/9006-default-config-test-case.patch
    - debian/patches/fix-block-migration.patch
    - debian/patches/ubuntu/9022-qemu-unescape-HMP-commands-before-converting-them-to.patch
    - debian/patches/ubuntu/9023-qemu-change-rbd-auth_supported-separation-character-.patch
    - debian/patches/ubuntu/9024-qemu-allow-snapshotting-of-sheepdog-and-rbd-disks.patch
    - debian/patches/9025-qemu-change-rbd-auth_supported-separation-character-.patch
    - debian/patches/ubuntu/arm-gcc-workaround.patch
  * Rediffed:
    - debian/patches/Allow-libvirt-group-to-access-the-socket.patch
    - debian/patches/Disable-failing-virnetsockettest.patch
    - debian/patches/dnsmasq-as-priv-user
    - debian/patches/9002-better_default_uri_virsh.patch
  * debian/control: Add libnl-route-3-dev ass a build depends.
  * debian/patches/libnl3-build-fix.patch: Fix build with libnl3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
            goto err_exit;
150
150
        }
151
151
 
152
 
        if (virMutexInitRecursive(&ifaceLock->lock)) {
 
152
        if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
153
153
            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
154
154
                                   _("mutex initialization failed"));
155
155
            VIR_FREE(ifaceLock);
184
184
 err_exit:
185
185
    virMutexUnlock(&ifaceMapLock);
186
186
 
187
 
    return 1;
 
187
    return -1;
188
188
}
189
189
 
190
190
 
248
248
 
249
249
int
250
250
virNWFilterTerminateLearnReq(const char *ifname) {
251
 
    int rc = 1;
 
251
    int rc = -1;
252
252
    int ifindex;
253
253
    virNWFilterIPAddrLearnReqPtr req;
254
254
 
336
336
            goto cleanup;
337
337
        }
338
338
        ret = virNWFilterHashTablePut(ipAddressMap, ifname, val, 1);
339
 
        /* FIXME: fix when return code of virNWFilterHashTablePut changes */
340
 
        if (ret)
341
 
            ret = -1;
342
339
        goto cleanup;
343
340
    } else {
344
341
        if (virNWFilterVarValueAddValue(val, addr) < 0)
494
491
    enum howDetect howDetected = 0;
495
492
    virNWFilterTechDriverPtr techdriver = req->techdriver;
496
493
 
497
 
    if (virNWFilterLockIface(req->ifname))
 
494
    if (virNWFilterLockIface(req->ifname) < 0)
498
495
       goto err_no_lock;
499
496
 
500
497
    req->status = 0;
514
511
        goto done;
515
512
    }
516
513
 
517
 
    virFormatMacAddr(req->macaddr, macaddr);
 
514
    virMacAddrFormat(req->macaddr, macaddr);
518
515
 
519
516
    switch (req->howDetect) {
520
517
    case DETECT_DHCP:
521
518
        if (techdriver->applyDHCPOnlyRules(req->ifname,
522
519
                                           req->macaddr,
523
 
                                           NULL, false)) {
 
520
                                           NULL, false) < 0) {
524
521
            req->status = EINVAL;
525
522
            goto done;
526
523
        }
530
527
        break;
531
528
    default:
532
529
        if (techdriver->applyBasicRules(req->ifname,
533
 
                                        req->macaddr)) {
 
530
                                        req->macaddr) < 0) {
534
531
            req->status = EINVAL;
535
532
            goto done;
536
533
        }
701
698
        sa.data.inet4.sin_addr.s_addr = vmaddr;
702
699
        char *inetaddr;
703
700
 
704
 
        if ((inetaddr = virSocketAddrFormat(&sa))!= NULL) {
 
701
        if ((inetaddr = virSocketAddrFormat(&sa)) != NULL) {
705
702
            if (virNWFilterAddIpAddrForIfname(req->ifname, inetaddr) < 0) {
706
703
                VIR_ERROR(_("Failed to add IP address %s to IP address "
707
704
                          "cache for interface %s"), inetaddr, req->ifname);
708
705
            }
709
706
 
710
 
            ret = virNWFilterInstantiateFilterLate(req->ifname,
 
707
            ret = virNWFilterInstantiateFilterLate(NULL,
 
708
                                                   req->ifname,
711
709
                                                   req->ifindex,
712
710
                                                   req->linkdev,
713
711
                                                   req->nettype,
781
779
    virNWFilterHashTablePtr ht = NULL;
782
780
 
783
781
    if (howDetect == 0)
784
 
        return 1;
 
782
        return -1;
785
783
 
786
784
    if ( !techdriver->canApplyBasicRules()) {
787
785
        virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
788
786
                               _("IP parameter must be provided since "
789
787
                                 "snooping the IP address does not work "
790
788
                                 "possibly due to missing tools"));
791
 
        return 1;
 
789
        return -1;
792
790
    }
793
791
 
794
792
    if (VIR_ALLOC(req) < 0) {
802
800
        goto err_free_req;
803
801
    }
804
802
 
805
 
    if (virNWFilterHashTablePutAll(filterparams, ht))
 
803
    if (virNWFilterHashTablePutAll(filterparams, ht) < 0)
806
804
        goto err_free_ht;
807
805
 
808
806
    req->filtername = strdup(filtername);
838
836
 
839
837
    rc = virNWFilterRegisterLearnReq(req);
840
838
 
841
 
    if (rc)
 
839
    if (rc < 0)
842
840
        goto err_free_req;
843
841
 
844
842
    if (pthread_create(&req->thread,
856
854
err_free_req:
857
855
    virNWFilterIPAddrLearnReqFree(req);
858
856
err_no_req:
859
 
    return 1;
 
857
    return -1;
860
858
}
861
859
 
862
860
#else
876
874
                           _("IP parameter must be given since libvirt "
877
875
                             "was not compiled with IP address learning "
878
876
                             "support"));
879
 
    return 1;
 
877
    return -1;
880
878
}
881
879
#endif /* HAVE_LIBPCAP */
882
880
 
895
893
 
896
894
    pendingLearnReq = virHashCreate(0, freeLearnReqEntry);
897
895
    if (!pendingLearnReq) {
898
 
        return 1;
 
896
        return -1;
899
897
    }
900
898
 
901
 
    if (virMutexInit(&pendingLearnReqLock)) {
 
899
    if (virMutexInit(&pendingLearnReqLock) < 0) {
902
900
        virNWFilterLearnShutdown();
903
 
        return 1;
 
901
        return -1;
904
902
    }
905
903
 
906
904
    ipAddressMap = virNWFilterHashTableCreate(0);
907
905
    if (!ipAddressMap) {
908
906
        virReportOOMError();
909
907
        virNWFilterLearnShutdown();
910
 
        return 1;
 
908
        return -1;
911
909
    }
912
910
 
913
 
    if (virMutexInit(&ipAddressMapLock)) {
 
911
    if (virMutexInit(&ipAddressMapLock) < 0) {
914
912
        virNWFilterLearnShutdown();
915
 
        return 1;
 
913
        return -1;
916
914
    }
917
915
 
918
916
    ifaceLockMap = virHashCreate(0, freeIfaceLock);
919
917
    if (!ifaceLockMap) {
920
918
        virNWFilterLearnShutdown();
921
 
        return 1;
 
919
        return -1;
922
920
    }
923
921
 
924
 
    if (virMutexInit(&ifaceMapLock)) {
 
922
    if (virMutexInit(&ifaceMapLock) < 0) {
925
923
        virNWFilterLearnShutdown();
926
 
        return 1;
 
924
        return -1;
927
925
    }
928
926
 
929
927
    return 0;