bgpd: simplify ebgp-multihop and ttl-security handling

Change to track configured value in ->ttl and ->gtsm_hops;
not the value set to sockopt. Instead, setting of socket's ttl
and minttl options are now merged to one function which calculates
it on demand. This greatly simplifies the code.
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 7af4e81..8eeaff9 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -3058,7 +3058,7 @@
   if (! peer)
     return CMD_WARNING;
 
-  return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
+  return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, 0));
 }
 
 /* neighbor ebgp-multihop. */
@@ -4380,7 +4380,7 @@
   if (! peer)
     return CMD_WARNING;
 
-  return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
+  return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, 0));
 }
 
 /* Address family configuration.  */
@@ -8364,6 +8364,7 @@
   char timebuf[BGP_UPTIME_LEN];
   afi_t afi;
   safi_t safi;
+  int ttl;
 
   bgp = p->bgp;
 
@@ -8663,21 +8664,12 @@
     }
 
   /* EBGP Multihop and GTSM */
-  if (p->sort != BGP_PEER_IBGP)
-    {
-      if (p->gtsm_hops > 0)
-	vty_out (vty, "  External BGP neighbor may be up to %d hops away.%s",
-		 p->gtsm_hops, VTY_NEWLINE);
-      else if (p->ttl > 1)
-	vty_out (vty, "  External BGP neighbor may be up to %d hops away.%s",
-		 p->ttl, VTY_NEWLINE);
-    }
-  else
-    {
-      if (p->gtsm_hops > 0)
-	vty_out (vty, "  Internal BGP neighbor may be up to %d hops away.%s",
-		 p->gtsm_hops, VTY_NEWLINE);
-    }
+  ttl = p->gtsm_hops;
+  if (! ttl)
+    ttl = peer_ttl (p);
+  vty_out (vty, "  %s BGP neighbor may be up to %d hops away.%s",
+           p->sort == BGP_PEER_IBGP ? "Internal" : "External",
+           ttl, VTY_NEWLINE);
 
   /* Local address. */
   if (p->su_local)