Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 13.47 KB | None | 0 0
  1. commit 2d661a2733010d7e94560c624edbe7f192952b3d
  2. Author: Numan Siddique <nusiddiq@redhat.com>
  3. Date:   Wed Oct 10 11:38:55 2018 +0530
  4.  
  5.     ovn: Support configuring the BFD params for the tunnel interfaces
  6.    
  7.     With this commit the users can override the default values of
  8.     the BFD params - min_rx, min_tx, decay_min_rx and mult if desired.
  9.     This can be useful to debug any issues related to BFD (like
  10.     frequent BFD state changes).
  11.    
  12.     A new column 'options' is added in NB_Global and SB_Global tables
  13.     of OVN_Northbound and OVN_Southbound schemas respectively. CMS
  14.     can define the options 'bfd-min-rx', 'bfd-min-tx',
  15.     'bfd-decay-min-rx' and 'bfd-mult' in the options column of
  16.     NB_Global table row. ovn-northd copies these options from
  17.     NB_Global to SB_Global. ovn-controller configures these
  18.     options to the tunnel interfaces when enabling BFD.
  19.    
  20.     When BFD is disabled, this patch now clears the 'bfd' column
  21.     of the interface row, instead of setting 'enable=false'.
  22.    
  23.     Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
  24.     Signed-off-by: Ben Pfaff <blp@ovn.org>
  25.  
  26. --- a/ovn/controller/bfd.c
  27. +++ b/ovn/controller/bfd.c
  28. @@ -38,24 +38,6 @@ bfd_register_ovs_idl(struct ovsdb_idl *o
  29.      ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_bfd_status);
  30.  }
  31.  
  32. -
  33. -static void
  34. -interface_set_bfd(const struct ovsrec_interface *iface, bool bfd_setting)
  35. -{
  36. -    const char *new_setting = bfd_setting ? "true":"false";
  37. -    const char *current_setting = smap_get(&iface->bfd, "enable");
  38. -    if (current_setting && !strcmp(current_setting, new_setting)) {
  39. -        /* If already set to the desired setting we skip setting it again
  40. -         * to avoid flapping to bfd initialization state */
  41. -        return;
  42. -    }
  43. -    const struct smap bfd = SMAP_CONST1(&bfd, "enable", new_setting);
  44. -    ovsrec_interface_verify_bfd(iface);
  45. -    ovsrec_interface_set_bfd(iface, &bfd);
  46. -    VLOG_INFO("%s BFD on interface %s", bfd_setting ? "Enabled" : "Disabled",
  47. -                                        iface->name);
  48. -}
  49. -
  50.  void
  51.  bfd_calculate_active_tunnels(const struct ovsrec_bridge *br_int,
  52.                               struct sset *active_tunnels)
  53. @@ -267,6 +249,7 @@ bfd_run(struct ovsdb_idl_index *sbrec_ch
  54.          const struct ovsrec_interface_table *interface_table,
  55.          const struct ovsrec_bridge *br_int,
  56.          const struct sbrec_chassis *chassis_rec,
  57. +        const struct sbrec_sb_global_table *sb_global_table,
  58.          const struct hmap *local_datapaths)
  59.  {
  60.  
  61. @@ -292,15 +275,58 @@ bfd_run(struct ovsdb_idl_index *sbrec_ch
  62.          }
  63.      }
  64.  
  65. +    const struct sbrec_sb_global *sb
  66. +        = sbrec_sb_global_table_first(sb_global_table);
  67. +    struct smap bfd = SMAP_INITIALIZER(&bfd);
  68. +    smap_add(&bfd, "enable", "true");
  69. +
  70. +    if (sb) {
  71. +        const char *min_rx = smap_get(&sb->options, "bfd-min-rx");
  72. +        const char *decay_min_rx = smap_get(&sb->options, "bfd-decay-min-rx");
  73. +        const char *min_tx = smap_get(&sb->options, "bfd-min-tx");
  74. +        const char *mult = smap_get(&sb->options, "bfd-mult");
  75. +        if (min_rx) {
  76. +            smap_add(&bfd, "min_rx", min_rx);
  77. +        }
  78. +        if (decay_min_rx) {
  79. +            smap_add(&bfd, "decay_min_rx", decay_min_rx);
  80. +        }
  81. +        if (min_tx) {
  82. +            smap_add(&bfd, "min_tx", min_tx);
  83. +        }
  84. +        if (mult) {
  85. +            smap_add(&bfd, "mult", mult);
  86. +        }
  87. +    }
  88. +
  89.      /* Enable or disable bfd */
  90.      const struct ovsrec_interface *iface;
  91.      OVSREC_INTERFACE_TABLE_FOR_EACH (iface, interface_table) {
  92.          if (sset_contains(&tunnels, iface->name)) {
  93. -                interface_set_bfd(
  94. -                        iface, sset_contains(&bfd_ifaces, iface->name));
  95. +            if (sset_contains(&bfd_ifaces, iface->name)) {
  96. +                /* We need to enable BFD for this interface. Configure the
  97. +                 * BFD params if
  98. +                 *  - If BFD was disabled earlier
  99. +                 *  - Or if CMS has updated BFD config options.
  100. +                 */
  101. +                if (!smap_equal(&iface->bfd, &bfd)) {
  102. +                    ovsrec_interface_verify_bfd(iface);
  103. +                    ovsrec_interface_set_bfd(iface, &bfd);
  104. +                    VLOG_INFO("Enabled BFD on interface %s", iface->name);
  105. +                }
  106. +            } else {
  107. +                /* We need to disable BFD for this interface if it was enabled
  108. +                 * earlier. */
  109. +                if (smap_count(&iface->bfd)) {
  110. +                    ovsrec_interface_verify_bfd(iface);
  111. +                    ovsrec_interface_set_bfd(iface, NULL);
  112. +                    VLOG_INFO("Disabled BFD on interface %s", iface->name);
  113. +                }
  114. +            }
  115.           }
  116.      }
  117.  
  118. +    smap_destroy(&bfd);
  119.      sset_destroy(&tunnels);
  120.      sset_destroy(&bfd_ifaces);
  121.      sset_destroy(&bfd_chassis);
  122. --- a/ovn/controller/bfd.h
  123. +++ b/ovn/controller/bfd.h
  124. @@ -21,7 +21,9 @@ struct ovsdb_idl;
  125.  struct ovsdb_idl_index;
  126.  struct ovsrec_bridge;
  127.  struct ovsrec_interface_table;
  128. +struct ovsrec_open_vswitch_table;
  129.  struct sbrec_chassis;
  130. +struct sbrec_sb_global_table;
  131.  struct sset;
  132.  
  133.  void bfd_register_ovs_idl(struct ovsdb_idl *);
  134. @@ -30,6 +32,7 @@ void bfd_run(struct ovsdb_idl_index *sbr
  135.               const struct ovsrec_interface_table *interface_table,
  136.               const struct ovsrec_bridge *br_int,
  137.               const struct sbrec_chassis *chassis_rec,
  138. +             const struct sbrec_sb_global_table *sb_global_table,
  139.               const struct hmap *local_datapaths);
  140.  void  bfd_calculate_active_tunnels(const struct ovsrec_bridge *br_int,
  141.                                     struct sset *active_tunnels);
  142. --- a/ovn/controller/ovn-controller.c
  143. +++ b/ovn/controller/ovn-controller.c
  144. @@ -768,7 +768,9 @@ main(int argc, char *argv[])
  145.                          bfd_run(sbrec_chassis_by_name,
  146.                                  sbrec_port_binding_by_datapath,
  147.                                  ovsrec_interface_table_get(ovs_idl_loop.idl),
  148. -                                br_int, chassis, &local_datapaths);
  149. +                                br_int, chassis,
  150. +                                sbrec_sb_global_table_get(ovnsb_idl_loop.idl),
  151. +                                &local_datapaths);
  152.                      }
  153.                      physical_run(
  154.                          sbrec_chassis_by_name,
  155. --- a/ovn/northd/ovn-northd.c
  156. +++ b/ovn/northd/ovn-northd.c
  157. @@ -7106,6 +7106,7 @@ ovnnb_db_run(struct northd_context *ctx,
  158.          sb = sbrec_sb_global_insert(ctx->ovnsb_txn);
  159.      }
  160.      sbrec_sb_global_set_nb_cfg(sb, nb->nb_cfg);
  161. +    sbrec_sb_global_set_options(sb, &nb->options);
  162.      sb_loop->next_cfg = nb->nb_cfg;
  163.  
  164.      cleanup_macam(&macam);
  165. @@ -7609,6 +7610,7 @@ main(int argc, char *argv[])
  166.  
  167.      ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_sb_global);
  168.      add_column_noalert(ovnsb_idl_loop.idl, &sbrec_sb_global_col_nb_cfg);
  169. +    add_column_noalert(ovnsb_idl_loop.idl, &sbrec_sb_global_col_options);
  170.  
  171.      ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_logical_flow);
  172.      add_column_noalert(ovnsb_idl_loop.idl,
  173. --- a/ovn/ovn-nb.ovsschema
  174. +++ b/ovn/ovn-nb.ovsschema
  175. @@ -1,7 +1,7 @@
  176.  {
  177.      "name": "OVN_Northbound",
  178. -    "version": "5.13.0",
  179. -    "cksum": "1278623084 20312",
  180. +    "version": "5.13.1",
  181. +    "cksum": "749176366 20467",
  182.      "tables": {
  183.          "NB_Global": {
  184.              "columns": {
  185. @@ -19,7 +19,10 @@
  186.                  "ssl": {
  187.                      "type": {"key": {"type": "uuid",
  188.                                       "refTable": "SSL"},
  189. -                                     "min": 0, "max": 1}}},
  190. +                                     "min": 0, "max": 1}},
  191. +                "options": {
  192. +                    "type": {"key": "string", "value": "string",
  193. +                             "min": 0, "max": "unlimited"}}},
  194.              "maxRows": 1,
  195.              "isRoot": true},
  196.          "Logical_Switch": {
  197. --- a/ovn/ovn-nb.xml
  198. +++ b/ovn/ovn-nb.xml
  199. @@ -69,6 +69,41 @@
  200.          See <em>External IDs</em> at the beginning of this document.
  201.        </column>
  202.      </group>
  203. +
  204. +    <group title="Common options">
  205. +      <column name="options">
  206. +        This column provides general key/value settings. The supported
  207. +        options are described individually below.
  208. +      </column>
  209. +
  210. +      <group title="Options for configuring BFD">
  211. +        <p>
  212. +          These options apply when <code>ovn-controller</code> configures
  213. +          BFD on tunnels interfaces.
  214. +        </p>
  215. +
  216. +        <column name="options" key="bfd-min-rx">
  217. +          BFD option <code>min-rx</code> value to use when configuring BFD on
  218. +          tunnel interfaces.
  219. +        </column>
  220. +
  221. +        <column name="options" key="bfd-decay-min-rx">
  222. +          BFD option <code>decay-min-rx</code> value to use when configuring
  223. +          BFD on tunnel interfaces.
  224. +        </column>
  225. +
  226. +        <column name="options" key="bfd-min-tx">
  227. +          BFD option <code>min-tx</code> value to use when configuring BFD on
  228. +          tunnel interfaces.
  229. +        </column>
  230. +
  231. +        <column name="options" key="bfd-mult">
  232. +          BFD option <code>mult</code> value to use when configuring BFD on
  233. +          tunnel interfaces.
  234. +        </column>
  235. +      </group>
  236. +    </group>
  237. +
  238.      <group title="Connection Options">
  239.        <column name="connections">
  240.          Database clients to which the Open vSwitch database server should
  241. --- a/ovn/ovn-sb.ovsschema
  242. +++ b/ovn/ovn-sb.ovsschema
  243. @@ -1,7 +1,7 @@
  244.  {
  245.      "name": "OVN_Southbound",
  246. -    "version": "1.16.0",
  247. -    "cksum": "3046632234 14844",
  248. +    "version": "1.16.1",
  249. +    "cksum": "2148542239 14999",
  250.      "tables": {
  251.          "SB_Global": {
  252.              "columns": {
  253. @@ -17,7 +17,10 @@
  254.                  "ssl": {
  255.                      "type": {"key": {"type": "uuid",
  256.                                       "refTable": "SSL"},
  257. -                                     "min": 0, "max": 1}}},
  258. +                                     "min": 0, "max": 1}},
  259. +                "options": {
  260. +                    "type": {"key": "string", "value": "string",
  261. +                             "min": 0, "max": "unlimited"}}},
  262.              "maxRows": 1,
  263.              "isRoot": true},
  264.          "Chassis": {
  265. --- a/ovn/ovn-sb.xml
  266. +++ b/ovn/ovn-sb.xml
  267. @@ -162,7 +162,45 @@
  268.        <column name="external_ids">
  269.          See <em>External IDs</em> at the beginning of this document.
  270.        </column>
  271. +
  272. +      <column name="options">
  273. +      </column>
  274. +    </group>
  275. +
  276. +    <group title="Common options">
  277. +      <column name="options">
  278. +        This column provides general key/value settings. The supported
  279. +        options are described individually below.
  280. +      </column>
  281. +
  282. +      <group title="Options for configuring BFD">
  283. +        <p>
  284. +          These options apply when <code>ovn-controller</code> configures
  285. +          BFD on tunnels interfaces.
  286. +        </p>
  287. +
  288. +        <column name="options" key="bfd-min-rx">
  289. +          BFD option <code>min-rx</code> value to use when configuring BFD on
  290. +          tunnel interfaces.
  291. +        </column>
  292. +
  293. +        <column name="options" key="bfd-decay-min-rx">
  294. +          BFD option <code>decay-min-rx</code> value to use when configuring
  295. +          BFD on tunnel interfaces.
  296. +        </column>
  297. +
  298. +        <column name="options" key="bfd-min-tx">
  299. +          BFD option <code>min-tx</code> value to use when configuring BFD on
  300. +          tunnel interfaces.
  301. +        </column>
  302. +
  303. +        <column name="options" key="bfd-mult">
  304. +          BFD option <code>mult</code> value to use when configuring BFD on
  305. +          tunnel interfaces.
  306. +        </column>
  307. +      </group>
  308.      </group>
  309. +
  310.      <group title="Connection Options">
  311.        <column name="connections">
  312.          Database clients to which the Open vSwitch database server should
  313. --- a/tests/ovn.at
  314. +++ b/tests/ovn.at
  315. @@ -9055,7 +9055,7 @@ for chassis in gw1 gw2; do
  316.  done
  317.  # make sure BFD is not enabled to hv2, we don't need it
  318.  AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0],
  319. -         [[enable=false
  320. +         [[
  321.  ]])
  322.  
  323.  
  324. @@ -9069,7 +9069,7 @@ for chassis in gw1 gw2; do
  325.  done
  326.  # make sure BFD is not enabled to hv1, we don't need it
  327.  AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-0],[0],
  328. -         [[enable=false
  329. +         [[
  330.  ]])
  331.  
  332.  sleep 3  # let BFD sessions settle so we get the right flows on the right chassis
  333. @@ -9099,6 +9099,33 @@ AT_CHECK([ovn-sbctl --columns chassis --
  334.           [0],[[1
  335.  ]])
  336.  
  337. +ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-rx"=2000
  338. +as gw2
  339. +for chassis in gw1 hv1 hv2; do
  340. +    echo "checking gw2 -> $chassis"
  341. +    OVS_WAIT_UNTIL([
  342. +    bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0)
  343. +    test "$bfd_cfg" = "enable=true min_rx=2000"
  344. +])
  345. +done
  346. +ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-tx"=1500
  347. +for chassis in gw1 hv1 hv2; do
  348. +    echo "checking gw2 -> $chassis"
  349. +    OVS_WAIT_UNTIL([
  350. +    bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0)
  351. +    test "$bfd_cfg" = "enable=true min_rx=2000 min_tx=1500"
  352. +])
  353. +done
  354. +ovn-nbctl remove NB_Global . options "bfd-min-rx"
  355. +ovn-nbctl --wait=hv set NB_Global . options:"bfd-mult"=5
  356. +for chassis in gw1 hv1 hv2; do
  357. +    echo "checking gw2 -> $chassis"
  358. +    OVS_WAIT_UNTIL([
  359. +    bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0)
  360. +    test "$bfd_cfg" = "enable=true min_tx=1500 mult=5"
  361. +])
  362. +done
  363. +
  364.  OVN_CLEANUP([gw1],[gw2],[hv1],[hv2])
  365.  
  366.  AT_CLEANUP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement