]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: work around mtu error on iface+ settings 2137/head
authorVictor Julien <victor@inliniac.net>
Fri, 3 Jun 2016 10:38:08 +0000 (12:38 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 3 Jun 2016 10:38:08 +0000 (12:38 +0200)
src/suricata.c

index c5c1c3a2f1866352c9acd832376997223b42b9e0..5482002a54974d0fff27871c27fdb952c23330ce 100644 (file)
@@ -2182,15 +2182,30 @@ static int ConfigGetCaptureValue(SCInstance *suri)
     if ((ConfGet("default-packet-size", &temp_default_packet_size)) != 1) {
         int lthread;
         int nlive;
+        int strip_trailing_plus = 0;
         switch (suri->run_mode) {
             case RUNMODE_PCAP_DEV:
             case RUNMODE_AFP_DEV:
             case RUNMODE_NETMAP:
+                /* in netmap igb0+ has a special meaning, however the
+                 * interface really is igb0 */
+                strip_trailing_plus = 1;
+                /* fall through */
             case RUNMODE_PFRING:
                 nlive = LiveGetDeviceCount();
                 for (lthread = 0; lthread < nlive; lthread++) {
                     char *live_dev = LiveGetDeviceName(lthread);
-                    unsigned int iface_max_packet_size = GetIfaceMaxPacketSize(live_dev);
+                    char dev[32];
+                    (void)strlcpy(dev, live_dev, sizeof(dev));
+
+                    if (strip_trailing_plus) {
+                        size_t len = strlen(dev);
+                        if (len && dev[len-1] == '+') {
+                            dev[len-1] = '\0';
+                        }
+                    }
+
+                    unsigned int iface_max_packet_size = GetIfaceMaxPacketSize(dev);
                     if (iface_max_packet_size > default_packet_size)
                         default_packet_size = iface_max_packet_size;
                 }