9
0
Fork 0

mtp: Propagate link and linkset failures in two stages

Handle a single link failure in links.c and if all the
links have failed propagate it up. This is preparing the
multiple links support.
This commit is contained in:
Holger Hans Peter Freyther 2011-01-02 20:24:08 +01:00
parent 569f1e171d
commit c8405692b3
6 changed files with 54 additions and 46 deletions

View File

@ -1,7 +1,7 @@
/* Everything related to the BSC connection */
/*
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010 by On-Waves
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@ -126,8 +126,11 @@ struct bsc_data {
/* bsc related functions */
void release_bsc_resources(struct bsc_data *bsc);
void bsc_link_down(struct link_data *data);
void bsc_link_up(struct link_data *data);
void mtp_link_down(struct link_data *data);
void mtp_link_up(struct link_data *data);
void mtp_linkset_down(struct mtp_link_set *);
void mtp_linkset_up(struct mtp_link_set *);
/* msc related functions */
int msc_init(struct bsc_data *bsc, int mgcp);

View File

@ -1,6 +1,6 @@
/*
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010 by On-Waves
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@ -24,6 +24,8 @@
#include <osmocore/timer.h>
#include <osmocore/utils.h>
struct bsc_data;
/* MTP Level3 timers */
/* Timers for SS7 */
@ -60,6 +62,9 @@ struct mtp_link_set {
struct timer_list t2_timer;
struct timer_list delay_timer;
/* custom data */
struct bsc_data *bsc;
};

View File

@ -91,12 +91,12 @@ static int udp_read_cb(struct bsc_fd *fd)
if (hdr->data_type == UDP_DATA_RETR_COMPL || hdr->data_type == UDP_DATA_RETR_IMPOS) {
LOGP(DINP, LOGL_ERROR, "Link retrieval done. Restarting the link.\n");
bsc_link_down(link);
bsc_link_up(link);
mtp_link_down(link);
mtp_link_up(link);
goto exit;
} else if (hdr->data_type > UDP_DATA_MSU_PRIO_3) {
LOGP(DINP, LOGL_ERROR, "Link failure. retrieved message.\n");
bsc_link_down(link);
mtp_link_down(link);
goto exit;
}
@ -132,7 +132,7 @@ static void do_start(void *_data)
link->forced_down = 0;
snmp_mtp_activate(link->udp.session, link->udp.link_index);
bsc_link_up(link);
mtp_link_up(link);
}
static int udp_link_reset(struct link_data *link)
@ -140,7 +140,7 @@ static int udp_link_reset(struct link_data *link)
LOGP(DINP, LOGL_NOTICE, "Will restart SLTM transmission in %d seconds.\n",
link->udp.reset_timeout);
snmp_mtp_deactivate(link->udp.session, link->udp.link_index);
bsc_link_down(link);
mtp_link_down(link);
/* restart the link in 90 seconds... to force a timeout on the BSC */
link->link_activate.cb = do_start;

View File

@ -27,6 +27,17 @@
extern struct bsc_data bsc;
void mtp_link_down(struct link_data *link)
{
mtp_linkset_down(link->the_link);
link->clear_queue(link);
}
void mtp_link_up(struct link_data *link)
{
mtp_linkset_up(link->the_link);
}
void mtp_link_set_sccp_down(struct mtp_link_set *link)
{
}
@ -63,6 +74,7 @@ int link_init(struct bsc_data *bsc)
bsc->link.the_link->sltm_once = bsc->once;
bsc->link.the_link->ni = bsc->ni_ni;
bsc->link.the_link->spare = bsc->ni_spare;
bsc->link.the_link->bsc = bsc;
bsc->link.bsc = bsc;
bsc->link.udp.link_index = 1;

View File

@ -1,7 +1,7 @@
/* Bloated main routine, refactor */
/*
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010 by On-Waves
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@ -284,34 +284,28 @@ void release_bsc_resources(struct bsc_data *bsc)
}
}
void bsc_link_down(struct link_data *data)
void mtp_linkset_down(struct mtp_link_set *set)
{
int was_up;
struct mtp_link_set *link = data->the_link;
link->available = 0;
was_up = link->sccp_up;
mtp_link_set_stop(link);
clear_connections(data->bsc);
mgcp_reset(data->bsc);
data->clear_queue(data);
set->available = 0;
mtp_link_set_stop(set);
clear_connections(set->bsc);
mgcp_reset(set->bsc);
/* If we have an A link send a reset to the MSC */
msc_send_reset(data->bsc);
msc_send_reset(set->bsc);
}
void bsc_link_up(struct link_data *data)
void mtp_linkset_up(struct mtp_link_set *set)
{
data->the_link->available = 1;
set->available = 1;
/* we have not gone through link down */
if (data->bsc->msc_link_down) {
clear_connections(data->bsc);
bsc_resources_released(data->bsc);
if (set->bsc->msc_link_down) {
clear_connections(set->bsc);
bsc_resources_released(set->bsc);
}
mtp_link_set_reset(data->the_link);
mtp_link_set_reset(set);
}
/**

View File

@ -1,7 +1,7 @@
/* Relay UDT/all SCCP messages */
/*
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010 by On-Waves
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@ -70,25 +70,19 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
msc_send_direct(&bsc, _msg);
}
void bsc_link_down(struct link_data *data)
void mtp_linkset_down(struct mtp_link_set *set)
{
int was_up;
struct mtp_link_set *link = data->the_link;
link->available = 0;
was_up = link->sccp_up;
mtp_link_set_stop(link);
data->clear_queue(data);
set->available = 0;
mtp_link_set_stop(set);
/* If we have an A link send a reset to the MSC */
msc_send_reset(data->bsc);
msc_send_reset(set->bsc);
}
void bsc_link_up(struct link_data *data)
void mtp_linkset_up(struct mtp_link_set *set)
{
data->the_link->available = 1;
mtp_link_set_reset(data->the_link);
set->available = 1;
mtp_link_set_reset(set);
}
static void print_usage()