[pisa-src] r1089 - trunk/pisasd

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Mon, 12 Oct 2009 14:14:02 +0200

Author: tjansen
Date: Mon Oct 12 14:14:02 2009
New Revision: 1089

Log:
Performance optimization: Push MAC writing down to relevant cases.

No longer print MAC humanreadable to a buffer for each incoming legacy packet.
The buffer is only referenced by a few special cases (i. e. handover, new
connection) and not by the most frequently used case (i. e. established
connection). Only the special cases still print the MAC humanreadable.

Modified:
   trunk/pisasd/sdtun.c

Modified: trunk/pisasd/sdtun.c
==============================================================================
--- trunk/pisasd/sdtun.c        Mon Oct 12 12:46:41 2009        (r1088)
+++ trunk/pisasd/sdtun.c        Mon Oct 12 14:14:02 2009        (r1089)
@@ -95,14 +95,14 @@
                time(&entry->timeout_heartbeat);
 
                if (entry->type == PISA_CONTYPE_LEGACY_ROUTER) {
-                       char mac_str[ARP_STRLEN];
-                       pisa_mac_write_string(mac, mac_str);
                        map = pisa_nat_mapping_find_by_mac(sd_ctx.natlist, mac);
                        if ((mac->m[0] == 0) && (mac->m[1] == 0) && (mac->m[2] 
== 0) && (mac->m[3] == 0) && (mac->m[4] == 0) && (mac->m[5] == 0)) {
                                PISA_DEBUG(PL_DATA, "remote -> local: invalid 
MAC, dropping\n");
                                return;
                        }
                        if (map == NULL) {
+                               char mac_str[ARP_STRLEN];
+                               pisa_mac_write_string(mac, mac_str);
                                struct in_addr local = {0};
                                char ip_str[INET_ADDRSTRLEN];
                                if (pisa_client_get_legacy_client_ipv4(&local) 
== 0) {
@@ -114,6 +114,8 @@
                                PISA_DEBUG(PL_LEGACY, "Adding mapping for 
unknown legacy client: MAC %s IP %s\n", mac_str, ip_str);
                        } else {
                                if (map->connection != entry) {
+                                       char mac_str[ARP_STRLEN];
+                                       pisa_mac_write_string(mac, mac_str);
                                        PISA_DEBUG(PL_LEGACY, "Legacy client 
handover detected for MAC %s\n", mac_str);
                                        
pisa_nat_update_connection(sd_ctx.natlist, map, entry);
                                }

Other related posts:

  • » [pisa-src] r1089 - trunk/pisasd - Thomas Jansen