]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
[PMTUd] add support for pmtud_get for who doesn't want notifications
authorFabio M. Di Nitto <fdinitto@redhat.com>
Mon, 1 Dec 2014 13:45:08 +0000 (14:45 +0100)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Mon, 1 Dec 2014 13:45:08 +0000 (14:45 +0100)
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
libknet/handle.c
libknet/libknet.h
libknet/ping_test.c

index 48562748bd9dc0b8d1f0045cd6cc49d9782cc568..2feb6d41a72844ff595e961d67656f5b37b6df91 100644 (file)
@@ -792,6 +792,33 @@ int knet_handle_enable_pmtud_notify(knet_handle_t knet_h,
        return 0;
 }
 
+int knet_handle_pmtud_get(knet_handle_t knet_h,
+                         unsigned int *link_mtu,
+                         unsigned int *data_mtu)
+{
+       int savederrno = 0;
+
+       if (!knet_h) {
+               errno = EINVAL;
+               return -1;
+       }
+
+       savederrno = pthread_rwlock_rdlock(&knet_h->list_rwlock);
+       if (savederrno) {
+               log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s",
+                       strerror(savederrno));
+               errno = savederrno;
+               return -1;
+       }
+
+       *link_mtu = knet_h->link_mtu;
+       *data_mtu = knet_h->data_mtu;
+
+       pthread_rwlock_unlock(&knet_h->list_rwlock);
+
+       return 0;
+}
+
 int knet_handle_crypto(knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg)
 {
        int savederrno = 0;
index 6a4791490a51715cd5996e65395c662c827fba91..f6fd0b13eddea7b761edfc1fdd02d7dce5db4dd2 100644 (file)
@@ -210,6 +210,24 @@ int knet_handle_enable_pmtud_notify(knet_handle_t knet_h,
                                        unsigned int link_mtu,
                                        unsigned int data_mtu));
 
+/*
+ * knet_handle_pmtud_get
+ * 
+ * knet_h   - pointer to knet_handle_t
+ *
+ * link_mtu - pointer where to store link_mtu
+ * data_mtu - pointer where to store data_mtu (see above)
+ *
+ * knet_handle_pmtud_get returns:
+ *
+ * 0 on success
+ * -1 on error and errno is set.
+ */
+
+int knet_handle_pmtud_get(knet_handle_t knet_h,
+                               unsigned int *link_mtu,
+                               unsigned int *data_mtu);
+
 /*
  * knet_handle_crypto
  *
index 3d9d78013df0a85dae2c5f864ce22f592f2a8a39..3a77a13a4cee7279ae67c5cc536329334d3908f3 100644 (file)
@@ -282,6 +282,7 @@ int main(int argc, char *argv[])
        size_t host_ids_entries = 0;
        //int has_crypto = 0;
        int logfd;
+       unsigned int link_mtu = 0, data_mtu = 0;
 
        if (argc < 3) {
                print_usage(argv[0]);
@@ -319,6 +320,13 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
+       if (knet_handle_pmtud_get(knet_h, &link_mtu, &data_mtu)) {
+               printf("Unable to get PMTUd current values\n");
+               exit(EXIT_FAILURE);
+       } else {
+               printf("Current PMTUd: link %u data %u\n", link_mtu, data_mtu);
+       }
+
        if (knet_handle_enable_pmtud_notify(knet_h, pmtud_notify)) {
                printf("Unable to install PMTUd notification callback\n");
                exit(EXIT_FAILURE);