Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
By default setting route symetrical to YES
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 5 Nov 2010 15:09:12 +0000 (15:09 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 5 Nov 2010 15:09:12 +0000 (15:09 +0000)
Implement a function to compare if two routes are different.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8500 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/cunit_unit.c
src/surf/simgrid.dtd
src/surf/simgrid_dtd.c
src/surf/surf_routing.c
teshsuite/simdag/platforms/three_hosts_non_symmetric_route.xml
teshsuite/simdag/platforms/two_hosts_one_link_fullduplex.xml

index d333278..dc5aa8c 100644 (file)
@@ -8,7 +8,7 @@
 /* GENERATED FILE, DO NOT EDIT */
 /*******************************/
 
-#line 835 "xbt/cunit.c" 
+#line 826 "xbt/cunit.c" 
 
 
 XBT_TEST_UNIT("expect", test_expected_failure, "expected failures")
index 1dc2cfa..5b6e5db 100644 (file)
 <!ELEMENT route (link_ctn*)>
 <!ATTLIST route src CDATA #REQUIRED>
 <!ATTLIST route dst CDATA #REQUIRED>
-<!ATTLIST route symetrical (YES|NO) "NO">
+<!ATTLIST route symetrical (YES|NO) "YES">
 
 <!ELEMENT ASroute (link_ctn*)>
 <!ATTLIST ASroute src CDATA #REQUIRED>
 <!ATTLIST ASroute dst CDATA #REQUIRED>
 <!ATTLIST ASroute gw_src CDATA #REQUIRED>
 <!ATTLIST ASroute gw_dst CDATA #REQUIRED>
-<!ATTLIST ASroute symetrical (YES|NO) "NO">
+<!ATTLIST ASroute symetrical (YES|NO) "YES">
 
 <!ELEMENT link_ctn EMPTY>
 <!ATTLIST link_ctn id CDATA #REQUIRED>
index 5db2d80..24d2cfc 100644 (file)
@@ -2816,7 +2816,7 @@ int surf_parse__flex_debug = 0;
 #define YY_RESTORE_YY_MORE_OFFSET
 char *surf_parse_text;
 /* Validating XML processor for src/surf/simgrid.dtd.
- * Generated 2010/11/03 10:00:12.
+ * Generated 2010/11/04 11:16:46.
  *
  * This program was generated with the FleXML XML processor generator.
  * FleXML is Copyright (C) 1999-2005 Kristoffer Rose.  All rights reserved.
@@ -4957,7 +4957,7 @@ YY_RULE_SETUP
 {
   AX_surfxml_route_src = 0;
   AX_surfxml_route_dst = 0;
-  AX_surfxml_route_symetrical = A_surfxml_route_symetrical_NO;
+  AX_surfxml_route_symetrical = A_surfxml_route_symetrical_YES;
   ENTER(AL_surfxml_route); pushbuffer(0);
   }
        YY_BREAK
@@ -5067,7 +5067,7 @@ YY_RULE_SETUP
   AX_surfxml_ASroute_dst = 0;
   AX_surfxml_ASroute_gw_src = 0;
   AX_surfxml_ASroute_gw_dst = 0;
-  AX_surfxml_ASroute_symetrical = A_surfxml_ASroute_symetrical_NO;
+  AX_surfxml_ASroute_symetrical = A_surfxml_ASroute_symetrical_YES;
   ENTER(AL_surfxml_ASroute); pushbuffer(0);
   }
        YY_BREAK
index 4a8c742..51eeb16 100644 (file)
@@ -114,6 +114,7 @@ static void generic_set_ASroute(routing_component_t rc, const char *src,
 static void generic_set_bypassroute(routing_component_t rc,
                                     const char *src, const char *dst,
                                     route_extended_t e_route);
+int compare_routes(route_t route1, route_t route2);
 
 /* ************************************************************************** */
 /* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
@@ -2505,9 +2506,13 @@ static void generic_set_route(routing_component_t rc, const char *src,
   xbt_assert2(xbt_dynar_length(route->link_list) > 0,
               "Invalid count of links, must be greater than zero (%s,%s)",
               src, dst);
-  xbt_assert2(!xbt_dict_get_or_null(_parse_routes, route_name),
-              "The route between \"%s\" and \"%s\" already exist", src,
-              dst);
+
+  if( compare_routes(route,xbt_dict_get_or_null(_parse_routes, route_name)) )
+         xbt_die(bprintf("The route between \"%s\" and \"%s\" already exist", src,dst));
+
+//  xbt_assert2(!xbt_dict_get_or_null(_parse_routes, route_name),
+//              "The route between \"%s\" and \"%s\" already exist", src,
+//              dst);
 
   xbt_dict_set(_parse_routes, route_name, route, NULL);
   xbt_free(route_name);
@@ -2524,6 +2529,8 @@ static void generic_set_route(routing_component_t rc, const char *src,
                 xbt_dynar_push_as(route_sym->link_list ,char *, link_name);
          }
          DEBUG2("Load Route from \"%s\" to \"%s\"", dst, src);
+         if( compare_routes(route_sym,xbt_dict_get_or_null(_parse_routes, bprintf("%d#%d",*dst_id, *src_id))) )
+                 xbt_die(bprintf("The route between \"%s\" and \"%s\" already exist", dst,src));
          xbt_dict_set(_parse_routes, bprintf("%d#%d",*dst_id, *src_id), route_sym, NULL);
    }
 }
@@ -2552,9 +2559,10 @@ static void generic_set_ASroute(routing_component_t rc, const char *src,
   xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list) > 0,
               "Invalid count of links, must be greater than zero (%s,%s)",
               src, dst);
-  xbt_assert4(!xbt_dict_get_or_null(_parse_routes, route_name),
-              "The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",
-              src, e_route->src_gateway, dst, e_route->dst_gateway);
+
+  if( compare_routes((route_t) &(e_route->generic_route),xbt_dict_get_or_null(_parse_routes, route_name)) )
+  xbt_die(bprintf("The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",
+              src, e_route->src_gateway, dst, e_route->dst_gateway));
 
   xbt_dict_set(_parse_routes, route_name, e_route, NULL);
   xbt_free(route_name);
@@ -2576,6 +2584,11 @@ static void generic_set_ASroute(routing_component_t rc, const char *src,
          route_sym->dst_gateway = xbt_new0( char,strlen(e_route->src_gateway) );
          route_sym->dst_gateway = bprintf("%s",e_route->src_gateway);
          DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",dst, route_sym->src_gateway,src,route_sym->dst_gateway);
+
+         if( compare_routes((route_t) &(route_sym->generic_route),xbt_dict_get_or_null(_parse_routes,bprintf("%d#%d", *dst_id, *src_id))) )
+         xbt_die(bprintf("The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",
+                     dst, route_sym->src_gateway, src, route_sym->dst_gateway));
+
          xbt_dict_set(_parse_routes, bprintf("%d#%d", *dst_id, *src_id), route_sym, NULL);
    }
 }
@@ -3281,3 +3294,26 @@ void routing_store_route(void)
 {
   parse_E_route_store_route();
 }
+
+/*
+ * Compare two routes to know if the second route is in the table.
+ *  route1 : route to store
+ *  route2 : old route in the table
+ */
+int compare_routes(route_t route1, route_t route2)
+{
+       if(!route2) return 0;
+       if(xbt_dynar_length(route1->link_list) == xbt_dynar_length(route2->link_list))
+       {
+                 int i;
+                 int nb_links = xbt_dynar_length(route1->link_list);
+                 for(i=0 ; i<nb_links ; i++)
+                 {
+                        char *link_name1 = xbt_dynar_get_as(route1->link_list, i, char *);
+                        char *link_name2 = xbt_dynar_get_as(route2->link_list, i, char *);
+                        if(strcmp(link_name1,link_name2)) return 1;
+                 }
+                 return 0;
+       }
+       return 1;
+}
index fb58ad0..1081100 100644 (file)
    <link id="link2" bandwidth="125000000" latency="5E-5"/>
    <link id="link3" bandwidth="125000000" latency="5E-5"/>
  
-   <route src="bob" dst="alice">
+   <route src="bob" dst="alice" symetrical="NO">
      <link_ctn id="link1"/>
    </route>
-   <route src="alice" dst="bob">
+   <route src="alice" dst="bob" symetrical="NO">
      <link_ctn id="link2"/>
      <link_ctn id="link3"/>
    </route>
      <link_ctn id="link2"/>
    </route>
  
-   <route src="trudy" dst="bob">
-     <link_ctn id="link2"/>
-   </route>
    <route src="trudy" dst="alice">
      <link_ctn id="link3"/>
    </route>
-   <route src="alice" dst="trudy">
-     <link_ctn id="link3"/>
-   </route>
  </AS>
  </platform>
index 24cffdb..08904b4 100644 (file)
@@ -8,11 +8,11 @@
    <link id="link1" bandwidth="125000000" latency="5E-5"
    sharing_policy="FULLDUPLEX"/>
 
-   <route src="alice" dst="bob">
+   <route src="alice" dst="bob" symetrical="NO">
      <link_ctn id="link1" direction="UP"/>
    </route>
  
-   <route src="bob" dst="alice">
+   <route src="bob" dst="alice" symetrical="NO">
      <link_ctn id="link1" direction="DOWN"/>
    </route>