Commit Graph

18 Commits

Author SHA1 Message Date
Harald Welte 89ebea61e8 FrameRelay_Emulation: Fix network side emulation
On the network side, by definition all PVCs are always active.  Only the
user side detects the active PVCs from the network side.  In order to
make higher-layer code agnostic, we need to spoof the related status
events up the stack.

Change-Id: I791a7739e5ee6301ee5c24e5824a15a7b380a655
2021-02-16 19:59:20 +01:00
Harald Welte 9c6d89bdd1 FrameRelay_Emulation: Use Rx SeqNR == 0 to force link down
In quickly repeated test case executions we have the problem that
both the Q.933 LMI detection of link outage/interruption, as well as
the NS-ALIVE mechanism are too slow to detect the outage, and in fact
don't detect the outage.  This leads to inconsistent state on both
sides, with one side thinking NS-VCs are still ALIVE/UNBLOCKED, while
the other side considers them DEAD.

A Q.933 conforming transmittere would never send a sequece number of
zero, but always start from one.  This means we can use this as
a flag to force the peer to assume a "service affecting condition"
which will make it tell NS that the link went down, etc.

Related: OS#4974
Change-Id: I3e38ade112e11c86db906da9846a966cb33ac1bd
2021-02-04 18:20:06 +01:00
Harald Welte 3d6188304b FrameRelay_Emulation: Stop T392 if service failing condition
If the link is dead, there's no point in having timers running.  T392
will be re-started when the first Q.933 STATUS ENQUIRY is received.

Change-Id: I59b57d123d947cc358c670bc46f8c5df4597815e
2021-02-03 19:22:43 +01:00
Harald Welte 7d6688f9bc add module parameter "sleep_on_enobufs" to work around -ENOBUFS
AF_PACKET sockets have these incredibly useful semantics in where
for both non-blocking and blocking I/O, they will tell you the
socket is rwite-able, but then still return -1 and sett errno=ENOBUFS
if the current socket buffer / transmit queue is full.

All we can do is usleep and retry.  The new module parameter, if set
to non-zero, determines the number of microseconds we shall sleep before
any retry.  If set to zero, the existing behavior is preserved:
TTCN_error().

Related: SYS#5343
Change-Id: I1608403d94a10ae52c7e1de0f1b02687b048c01e
2021-01-29 21:29:17 +01:00
Harald Welte cd698095c7 guard against race between socket(AF_PACKET) and bind()
An AF_PACKET socket will immediately receive packets of _all_ interfaces
until it is bound to one specific interface.  This introduces a race
condition between the socket() and the bind() syscall.

Let's use the ifindex passed for each packet in recvmsg() to drop
any packets received for other interfaces.

Change-Id: Icd0b23eb1d6f75ca3a05e5dd1a569fa389903fdf
2020-12-10 21:55:10 +01:00
Harald Welte f42a8ae5c4 AF_PACKET_PT.cc: Remove superfluous #include to osmocom/core/utils.h
Change-Id: I2586ee726aea8f5d3edf397b2db2156bfafd7d8a
2020-11-18 13:03:55 +01:00
Harald Welte 77bdaebdd8 FrameRelay_Emulation: Add convenience template for PvcStatus 2020-09-14 08:48:25 +02:00
Harald Welte fd534cd48a FrameRelay_Emulation: Fix receiving FR from client/user 2020-09-14 08:48:10 +02:00
Harald Welte 19975d3377 FrameRelay_Emulation: Fix register/unregister (missing reply) 2020-09-14 08:47:41 +02:00
Harald Welte 6dfa78029e FrameRelay_Emulation: Fix detection of serivce-affecting condition
Before this patch, we would accidentially detect service-affecting
conditions at start-up until at least N393 cycles of T391 had expired.

Change-Id: I8bd8aa053a8d1ea3f1d366afdff2ceb69341e049
2020-09-14 08:10:37 +02:00
Harald Welte 43725e13b8 FrameRelay_Emulation: Don't increment tx sequence number twice 2020-09-13 23:43:42 +02:00
Harald Welte 01822abd58 FrameRelay_Emulation: Make T391 + T392 configurable 2020-09-13 23:43:37 +02:00
Harald Welte 17bf15b9dc notify clients of Q.933 reported state changes 2020-09-13 23:14:59 +02:00
Harald Welte aa9f4457b0 Various fixes discovered while actually using FrameRelay_Emulation
Change-Id: I7a537091c118173d7399aba20c82462aed9b6074
2020-09-13 23:14:39 +02:00
Harald Welte 9ea5e1f379 FrameRelay Emulation
Change-Id: I7a9c07bbf210c9ce18328ea39b2ef77d9f8dbd59
2020-09-11 21:18:58 +02:00
Harald Welte 2bca644911 Add Q931_Types + Q933_Tyeps with definitions from ITU-T Q.931 + Q.933
Change-Id: I722be710badeb92400f552929fd5769b858722af
2020-09-11 21:18:58 +02:00
Harald Welte d06088ddde Add FrameRelay_CodecPort on top of AF_PACKET_Port
Change-Id: I312d911847797a4d8fd8a4aab9046d99c806ff3a
2020-09-11 16:23:28 +02:00
Harald Welte 7f7437b0d7 initial check-in of new Linux AF_PACKET test port 2020-09-09 11:59:10 +02:00