Add an option to set source address for a BGP session.
When adding a BGP neighbour, one can set "update-source" (quagga syntax) to the source IP address that will be used for that session. Signed-off-by: Benjamin Cama <benoar@dolka.fr>
This commit is contained in:
parent
11ec3c4a24
commit
b36141c0c7
5 changed files with 51 additions and 3 deletions
30
cli.c
30
cli.c
|
|
@ -1038,6 +1038,11 @@ static int cmd_show_run(struct cli_def *cli, char *command, char **argv, int arg
|
|||
h = BGP_HOLD_TIME;
|
||||
|
||||
cli_print(cli, " neighbour %s timers %d %d", config->neighbour[i].name, k, h);
|
||||
|
||||
if (config->neighbour[i].update_source.s_addr != INADDR_ANY)
|
||||
cli_print(cli, " neighbour %s update-source %s",
|
||||
config->neighbour[i].name,
|
||||
inet_ntoa(config->neighbour[i].update_source));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2064,6 +2069,7 @@ static int cmd_router_bgp_neighbour(struct cli_def *cli, char *command, char **a
|
|||
return cli_arg_help(cli, 0,
|
||||
"remote-as", "Set remote autonomous system number",
|
||||
"timers", "Set timers",
|
||||
"update-source", "Set source address to use for the BGP session",
|
||||
NULL);
|
||||
|
||||
default:
|
||||
|
|
@ -2082,6 +2088,9 @@ static int cmd_router_bgp_neighbour(struct cli_def *cli, char *command, char **a
|
|||
return cli_arg_help(cli, 1, NULL);
|
||||
}
|
||||
|
||||
if (MATCH("update-source", argv[1]))
|
||||
return cli_arg_help(cli, argc > 3, "A.B.C.D", "Source IP address", NULL);
|
||||
|
||||
return CLI_OK;
|
||||
}
|
||||
}
|
||||
|
|
@ -2118,12 +2127,33 @@ static int cmd_router_bgp_neighbour(struct cli_def *cli, char *command, char **a
|
|||
snprintf(config->neighbour[i].name, sizeof(config->neighbour[i].name), "%s", argv[0]);
|
||||
config->neighbour[i].keepalive = -1;
|
||||
config->neighbour[i].hold = -1;
|
||||
config->neighbour[i].update_source.s_addr = INADDR_ANY;
|
||||
}
|
||||
|
||||
config->neighbour[i].as = as;
|
||||
return CLI_OK;
|
||||
}
|
||||
|
||||
if (MATCH("update-source", argv[1]))
|
||||
{
|
||||
struct in_addr addr;
|
||||
|
||||
if (!config->neighbour[i].name[0])
|
||||
{
|
||||
cli_error(cli, "Specify remote-as first");
|
||||
return CLI_OK;
|
||||
}
|
||||
|
||||
if (!inet_aton(argv[2], &addr))
|
||||
{
|
||||
cli_error(cli, "Cannot parse IP \"%s\"", argv[2]);
|
||||
return CLI_OK;
|
||||
}
|
||||
|
||||
config->neighbour[i].update_source = addr;
|
||||
return CLI_OK;
|
||||
}
|
||||
|
||||
if (argc != 4 || !MATCH("timers", argv[1]))
|
||||
{
|
||||
cli_error(cli, "Invalid arguments");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue