From: Pablo Neira Ayuso pablo@gnumonks.org
With multiple BTS attached to a single line, we have to call ->line_update() multiple times. I broke this myself while avoiding that A-bis over IP drivers bind to the socket several times.
To fix this situation, this patch adds the E1INP_DRV_F_LINE_ETHER flag which allows us to skip multiple invocation of ->line_update() only in case that this is an A-bis over IP driver.
Reported-by: Gus Bourg gus@bourg.net --- include/osmocom/abis/e1_input.h | 5 +++++ src/e1_input.c | 4 ++-- src/input/hsl.c | 1 + src/input/ipaccess.c | 1 + 4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 42b1758..bbbbf29 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -124,9 +124,14 @@ enum e1inp_line_role { E1INP_LINE_R_MAX };
+enum { + E1INP_DRV_F_LINE_ETHER = (1 << 0), /* Driver uses ethernet line. */ +}; + struct e1inp_driver { struct llist_head list; const char *name; + unsigned int flags; int (*want_write)(struct e1inp_ts *ts); int (*line_update)(struct e1inp_line *line); void (*close)(struct e1inp_sign_link *link); diff --git a/src/e1_input.c b/src/e1_input.c index a549ba4..3c5ac7d 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -676,8 +676,8 @@ int e1inp_line_update(struct e1inp_line *line)
e1inp_line_get(line);
- /* This line has been already initialized, skip this. */ - if (line->refcnt > 2) + /* This ethernet line has been already initialized, skip this. */ + if ((line->driver->flags & E1INP_DRV_F_LINE_ETHER) && line->refcnt > 2) return 0;
if (line->driver && line->ops && line->driver->line_update) { diff --git a/src/input/hsl.c b/src/input/hsl.c index dc7532b..fe9e70c 100644 --- a/src/input/hsl.c +++ b/src/input/hsl.c @@ -322,6 +322,7 @@ static int hsl_line_update(struct e1inp_line *line);
struct e1inp_driver hsl_driver = { .name = "hsl", + .flags = E1INP_DRV_F_LINE_ETHER, .want_write = ts_want_write, .line_update = hsl_line_update, .close = hsl_close, diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index b7391b3..b12383b 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -555,6 +555,7 @@ static int ipaccess_line_update(struct e1inp_line *line);
struct e1inp_driver ipaccess_driver = { .name = "ipa", + .flags = E1INP_DRV_F_LINE_ETHER, .want_write = ts_want_write, .line_update = ipaccess_line_update, .close = ipaccess_close,
Hi Pablo,
this is unfortunately not what I would like to see. The flag should be hidden in the ipaccess.c / hsl.c driver, and it should not be globally visible.
I think it's a bid odd to handle a special case like this in the generic code / data structure.
By definition, the driver has to cope with the fact that the line_update() function is called multiple times. That's what the name also indicates. If a driver wants to do something different, it has to solve the problem on the driver side.
Each driver can allocate its own structure and tie it to line->driver_data, like the misdn.c driver is doing it. In there it can handle local state like 'has this line been initialized before and do I thus want to skip another round of initialization'.
Regards, Harald