Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 13.42 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. @@ -248,7 +230,8 @@ bfd_calculate_chassis(struct controller_
  54.  void
  55.  bfd_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
  56.          const struct sbrec_chassis *chassis_rec, struct hmap *local_datapaths,
  57. -        const struct chassis_index *chassis_index)
  58. +        const struct chassis_index *chassis_index,
  59. +        const struct sbrec_sb_global_table *sb_global_table)
  60.  {
  61.  
  62.      if (!chassis_rec) {
  63. @@ -272,15 +255,58 @@ bfd_run(struct controller_ctx *ctx, cons
  64.          }
  65.      }
  66.  
  67. +    const struct sbrec_sb_global *sb
  68. +        = sbrec_sb_global_table_first(sb_global_table);
  69. +    struct smap bfd = SMAP_INITIALIZER(&bfd);
  70. +    smap_add(&bfd, "enable", "true");
  71. +
  72. +    if (sb) {
  73. +        const char *min_rx = smap_get(&sb->options, "bfd-min-rx");
  74. +        const char *decay_min_rx = smap_get(&sb->options, "bfd-decay-min-rx");
  75. +        const char *min_tx = smap_get(&sb->options, "bfd-min-tx");
  76. +        const char *mult = smap_get(&sb->options, "bfd-mult");
  77. +        if (min_rx) {
  78. +            smap_add(&bfd, "min_rx", min_rx);
  79. +        }
  80. +        if (decay_min_rx) {
  81. +            smap_add(&bfd, "decay_min_rx", decay_min_rx);
  82. +        }
  83. +        if (min_tx) {
  84. +            smap_add(&bfd, "min_tx", min_tx);
  85. +        }
  86. +        if (mult) {
  87. +            smap_add(&bfd, "mult", mult);
  88. +        }
  89. +    }
  90. +
  91.      /* Enable or disable bfd */
  92.      const struct ovsrec_interface *iface;
  93.      OVSREC_INTERFACE_FOR_EACH (iface, ctx->ovs_idl) {
  94.          if (sset_contains(&tunnels, iface->name)) {
  95. -                interface_set_bfd(
  96. -                        iface, sset_contains(&bfd_ifaces, iface->name));
  97. +            if (sset_contains(&bfd_ifaces, iface->name)) {
  98. +                /* We need to enable BFD for this interface. Configure the
  99. +                 * BFD params if
  100. +                 *  - If BFD was disabled earlier
  101. +                 *  - Or if CMS has updated BFD config options.
  102. +                 */
  103. +                if (!smap_equal(&iface->bfd, &bfd)) {
  104. +                    ovsrec_interface_verify_bfd(iface);
  105. +                    ovsrec_interface_set_bfd(iface, &bfd);
  106. +                    VLOG_INFO("Enabled BFD on interface %s", iface->name);
  107. +                }
  108. +            } else {
  109. +                /* We need to disable BFD for this interface if it was enabled
  110. +                 * earlier. */
  111. +                if (smap_count(&iface->bfd)) {
  112. +                    ovsrec_interface_verify_bfd(iface);
  113. +                    ovsrec_interface_set_bfd(iface, NULL);
  114. +                    VLOG_INFO("Disabled BFD on interface %s", iface->name);
  115. +                }
  116. +            }
  117.           }
  118.      }
  119.  
  120. +    smap_destroy(&bfd);
  121.      sset_destroy(&tunnels);
  122.      sset_destroy(&bfd_ifaces);
  123.      sset_destroy(&bfd_chassis);
  124. --- a/ovn/controller/bfd.h
  125. +++ b/ovn/controller/bfd.h
  126. @@ -21,13 +21,16 @@ struct controller_ctx;
  127.  struct hmap;
  128.  struct ovsdb_idl;
  129.  struct ovsrec_bridge;
  130. +struct ovsrec_open_vswitch_table;
  131.  struct sbrec_chassis;
  132. +struct sbrec_sb_global_table;
  133.  struct sset;
  134.  
  135.  void bfd_register_ovs_idl(struct ovsdb_idl *);
  136.  void bfd_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
  137.               const struct sbrec_chassis *chassis_rec,
  138. -             struct hmap *local_datapaths, const struct chassis_index *);
  139. +             struct hmap *local_datapaths, const struct chassis_index *,
  140. +             const struct sbrec_sb_global_table *sb_global_table);
  141.  void  bfd_calculate_active_tunnels(const struct ovsrec_bridge *br_int,
  142.                                     struct sset *active_tunnels);
  143.  
  144. --- a/ovn/controller/ovn-controller.c
  145. +++ b/ovn/controller/ovn-controller.c
  146. @@ -731,7 +731,8 @@ main(int argc, char *argv[])
  147.  
  148.                      if (chassis_id) {
  149.                          bfd_run(&ctx, br_int, chassis, &local_datapaths,
  150. -                                &chassis_index);
  151. +                                &chassis_index,
  152. +                                sbrec_sb_global_table_get(ovnsb_idl_loop.idl));
  153.                      }
  154.                      physical_run(&ctx, mff_ovn_geneve,
  155.                                   br_int, chassis, &ct_zones,
  156. --- a/ovn/northd/ovn-northd.c
  157. +++ b/ovn/northd/ovn-northd.c
  158. @@ -6458,6 +6458,7 @@ ovnnb_db_run(struct northd_context *ctx,
  159.          sb = sbrec_sb_global_insert(ctx->ovnsb_txn);
  160.      }
  161.      sbrec_sb_global_set_nb_cfg(sb, nb->nb_cfg);
  162. +    sbrec_sb_global_set_options(sb, &nb->options);
  163.      sb_loop->next_cfg = nb->nb_cfg;
  164.  
  165.      cleanup_macam(&macam);
  166. @@ -6956,6 +6957,7 @@ main(int argc, char *argv[])
  167.  
  168.      ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_sb_global);
  169.      add_column_noalert(ovnsb_idl_loop.idl, &sbrec_sb_global_col_nb_cfg);
  170. +    add_column_noalert(ovnsb_idl_loop.idl, &sbrec_sb_global_col_options);
  171.  
  172.      ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_logical_flow);
  173.      add_column_noalert(ovnsb_idl_loop.idl,
  174. --- a/ovn/ovn-nb.ovsschema
  175. +++ b/ovn/ovn-nb.ovsschema
  176. @@ -1,7 +1,7 @@
  177.  {
  178.      "name": "OVN_Northbound",
  179. -    "version": "5.10.0",
  180. -    "cksum": "626737541 17810",
  181. +    "version": "5.10.1",
  182. +    "cksum": "2509654490 17965",
  183.      "tables": {
  184.          "NB_Global": {
  185.              "columns": {
  186. @@ -19,7 +19,10 @@
  187.                  "ssl": {
  188.                      "type": {"key": {"type": "uuid",
  189.                                       "refTable": "SSL"},
  190. -                                     "min": 0, "max": 1}}},
  191. +                                     "min": 0, "max": 1}},
  192. +                "options": {
  193. +                    "type": {"key": "string", "value": "string",
  194. +                             "min": 0, "max": "unlimited"}}},
  195.              "maxRows": 1,
  196.              "isRoot": true},
  197.          "Logical_Switch": {
  198. --- a/ovn/ovn-nb.xml
  199. +++ b/ovn/ovn-nb.xml
  200. @@ -69,6 +69,41 @@
  201.          See <em>External IDs</em> at the beginning of this document.
  202.        </column>
  203.      </group>
  204. +
  205. +    <group title="Common options">
  206. +      <column name="options">
  207. +        This column provides general key/value settings. The supported
  208. +        options are described individually below.
  209. +      </column>
  210. +
  211. +      <group title="Options for configuring BFD">
  212. +        <p>
  213. +          These options apply when <code>ovn-controller</code> configures
  214. +          BFD on tunnels interfaces.
  215. +        </p>
  216. +
  217. +        <column name="options" key="bfd-min-rx">
  218. +          BFD option <code>min-rx</code> value to use when configuring BFD on
  219. +          tunnel interfaces.
  220. +        </column>
  221. +
  222. +        <column name="options" key="bfd-decay-min-rx">
  223. +          BFD option <code>decay-min-rx</code> value to use when configuring
  224. +          BFD on tunnel interfaces.
  225. +        </column>
  226. +
  227. +        <column name="options" key="bfd-min-tx">
  228. +          BFD option <code>min-tx</code> value to use when configuring BFD on
  229. +          tunnel interfaces.
  230. +        </column>
  231. +
  232. +        <column name="options" key="bfd-mult">
  233. +          BFD option <code>mult</code> value to use when configuring BFD on
  234. +          tunnel interfaces.
  235. +        </column>
  236. +      </group>
  237. +    </group>
  238. +
  239.      <group title="Connection Options">
  240.        <column name="connections">
  241.          Database clients to which the Open vSwitch database server should
  242. --- a/ovn/ovn-sb.ovsschema
  243. +++ b/ovn/ovn-sb.ovsschema
  244. @@ -1,7 +1,7 @@
  245.  {
  246.      "name": "OVN_Southbound",
  247. -    "version": "1.15.0",
  248. -    "cksum": "70426956 13327",
  249. +    "version": "1.15.1",
  250. +    "cksum": "4038624432 13482",
  251.      "tables": {
  252.          "SB_Global": {
  253.              "columns": {
  254. @@ -17,7 +17,10 @@
  255.                  "ssl": {
  256.                      "type": {"key": {"type": "uuid",
  257.                                       "refTable": "SSL"},
  258. -                                     "min": 0, "max": 1}}},
  259. +                                     "min": 0, "max": 1}},
  260. +                "options": {
  261. +                    "type": {"key": "string", "value": "string",
  262. +                             "min": 0, "max": "unlimited"}}},
  263.              "maxRows": 1,
  264.              "isRoot": true},
  265.          "Chassis": {
  266. --- a/ovn/ovn-sb.xml
  267. +++ b/ovn/ovn-sb.xml
  268. @@ -162,7 +162,45 @@
  269.        <column name="external_ids">
  270.          See <em>External IDs</em> at the beginning of this document.
  271.        </column>
  272. +
  273. +      <column name="options">
  274. +      </column>
  275. +    </group>
  276. +
  277. +    <group title="Common options">
  278. +      <column name="options">
  279. +        This column provides general key/value settings. The supported
  280. +        options are described individually below.
  281. +      </column>
  282. +
  283. +      <group title="Options for configuring BFD">
  284. +        <p>
  285. +          These options apply when <code>ovn-controller</code> configures
  286. +          BFD on tunnels interfaces.
  287. +        </p>
  288. +
  289. +        <column name="options" key="bfd-min-rx">
  290. +          BFD option <code>min-rx</code> value to use when configuring BFD on
  291. +          tunnel interfaces.
  292. +        </column>
  293. +
  294. +        <column name="options" key="bfd-decay-min-rx">
  295. +          BFD option <code>decay-min-rx</code> value to use when configuring
  296. +          BFD on tunnel interfaces.
  297. +        </column>
  298. +
  299. +        <column name="options" key="bfd-min-tx">
  300. +          BFD option <code>min-tx</code> value to use when configuring BFD on
  301. +          tunnel interfaces.
  302. +        </column>
  303. +
  304. +        <column name="options" key="bfd-mult">
  305. +          BFD option <code>mult</code> value to use when configuring BFD on
  306. +          tunnel interfaces.
  307. +        </column>
  308. +      </group>
  309.      </group>
  310. +
  311.      <group title="Connection Options">
  312.        <column name="connections">
  313.          Database clients to which the Open vSwitch database server should
  314. --- a/tests/ovn.at
  315. +++ b/tests/ovn.at
  316. @@ -8722,7 +8722,7 @@ for chassis in gw1 gw2; do
  317.  done
  318.  # make sure BFD is not enabled to hv2, we don't need it
  319.  AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0],
  320. -         [[enable=false
  321. +         [[
  322.  ]])
  323.  
  324.  
  325. @@ -8736,7 +8736,7 @@ for chassis in gw1 gw2; do
  326.  done
  327.  # make sure BFD is not enabled to hv1, we don't need it
  328.  AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-0],[0],
  329. -         [[enable=false
  330. +         [[
  331.  ]])
  332.  
  333.  sleep 3  # let BFD sessions settle so we get the right flows on the right chassis
  334. @@ -8766,6 +8766,33 @@ AT_CHECK([ovn-sbctl --columns chassis --
  335.           [0],[[1
  336.  ]])
  337.  
  338. +ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-rx"=2000
  339. +as gw2
  340. +for chassis in gw1 hv1 hv2; do
  341. +    echo "checking gw2 -> $chassis"
  342. +    OVS_WAIT_UNTIL([
  343. +    bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0)
  344. +    test "$bfd_cfg" = "enable=true min_rx=2000"
  345. +])
  346. +done
  347. +ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-tx"=1500
  348. +for chassis in gw1 hv1 hv2; do
  349. +    echo "checking gw2 -> $chassis"
  350. +    OVS_WAIT_UNTIL([
  351. +    bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0)
  352. +    test "$bfd_cfg" = "enable=true min_rx=2000 min_tx=1500"
  353. +])
  354. +done
  355. +ovn-nbctl remove NB_Global . options "bfd-min-rx"
  356. +ovn-nbctl --wait=hv set NB_Global . options:"bfd-mult"=5
  357. +for chassis in gw1 hv1 hv2; do
  358. +    echo "checking gw2 -> $chassis"
  359. +    OVS_WAIT_UNTIL([
  360. +    bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0)
  361. +    test "$bfd_cfg" = "enable=true min_tx=1500 mult=5"
  362. +])
  363. +done
  364. +
  365.  OVN_CLEANUP([gw1],[gw2],[hv1],[hv2])
  366.  
  367.  AT_CLEANUP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement