Commit Graph

1140 Commits (450b1ed844f6f5e0e2a0881b08a0afd1d6a2d76a)

Author SHA1 Message Date
Anders Selhammer b2f2c9e02d snmp4lptp: Add snmp sub agent for linuxptp
The sub agent use net-snmp library and AgentX protocol for the
communication towards the snmp master agent.
snmpd.c should only include general setup needed for handling snmp.
Supported MIBs should be implemented in separate files.
Makefile will include snmpd if libsnmp is available during compilation.
configs/snmpd.conf should be placed in /etc/snmp/

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-07 09:44:52 -07:00
Richard Cochran 059269d0cc Version 2.0
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-08-12 14:08:43 -07:00
Miroslav Lichvar 47971bdd50 port: Fix memory leaks.
In port_management_fill_response() the TLV descriptor leaked when
not responding.

In port_open() the port would leak with the unsupported management clock
type.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-08-12 13:33:06 -07:00
Miroslav Lichvar d08bee2771 Fix -Wformat-overflow warnings.
Two warnings were observed with gcc-8.1.1.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-08-12 13:29:39 -07:00
Richard Cochran a2740768b6 Apply ingress and egress latency corrections in P2P one step mode.
When using peer to peer one step mode, the normal time stamp handling
of peer delay request messages is bypassed.  The hardware subtracts
the ingress time stamp from the correction field and then adds the
egress time into the correction of the response.  The configured
latency values are never applied since the hardware has no knowledge
of them.  This patch adds in the correction values in this special
case.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-08-05 21:15:59 -07:00
Christoph Seifert da06ea5a3a config: logAnnounceInterval for 802.1AS
The default initial value for logAnnounceInterval should be 0 (once per second).
See chapter 10.6.2.2 of IEEE 802.1AS standard.

Signed-off-by: Christoph Seifert <christoph.seifert@posteo.me>
2018-08-02 09:25:58 -07:00
Michael Walle 57c2b46604 msg: inline net2host64() and host2net64()
These functions are just wrappers. Make it possible for the compiler to
optimize the calls when compiled with optimization.

Signed-off-by: Michael Walle <michael@walle.cc>
2018-07-21 16:28:07 -07:00
Michael Walle 8f484e8312 msg: Drop msg->tlv_count.
The field is redundant with the length tlv_list. Replace it with a
function msg_tlv_count() instead. This iterates over the tlv_list. The
computational overhead should be small, because the lists are very short
and the tlv_count is only used in management paths (yet).

Signed-off-by: Michael Walle <michael@walle.cc>
2018-07-21 16:28:07 -07:00
Michael Walle 427f1b3981 msg: Make msg_pre_send() and msg_post_recv() symmetrical
Since commit 7fe69e7ba0 management
messages are dropped in some cases because the tlv_count isn't 1.
Further analysis shows that this is the case when the message is
forwarded in clock_forward_mgmt_msg(). This is because msg_post_recv()
will append TLVs and - in the forwarding case - there is already one TLV
in the list, which results in tlv_count being 2 and thus dropped in
subsequent code.

msg_post_recv() is intended to be the cleanup code for msg_pre_send()
which is called earlier. Therefore, make msg_post_recv() and
msg_pre_send() symmetrical and cleanup the tlv_list and tlv_count.

Signed-off-by: Michael Walle <michael@walle.cc>
2018-07-21 16:28:07 -07:00
Andriy Kohut f977a653e0 pmc_common: Recycle message if allocation of tlv_extra failed
Change-Id: I4ed12f1cddcb85e8f55552ce8980a9d5f3f7d800
Signed-off-by: Andriy Kohut <andriyk@mellanox.com>
2018-07-19 10:31:06 -07:00
Anders Selhammer f32553b70a pdt: Added check if already defined
TRUE and FALSE is also defined in net-snmp library. Without this check,
compilation and includes must be made in a certain order.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-07-05 23:54:26 -07:00
Anders Selhammer d85c592993 pmc: Move new common funtionality into pmc_common
Code from pmc.c will be reused by new snmpd.c in later commit.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-07-05 23:17:32 -07:00
Michael Walle 763a7ecdb2 clock: Fix memleak in clock_management_fill_response()
If the message is ignored, the tlv_extra isn't freed. Fix this.

Signed-off-by: Michael Walle <michael@walle.cc>
2018-07-02 22:23:13 -07:00
Richard Cochran 6ba73d18b1 telecom: Add example configuration files.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:08 -07:00
Richard Cochran 0cb7abf703 Add example configuration files for unicast operation.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:08 -07:00
Richard Cochran 8144fa7546 Document the unicast configuration options.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:07 -07:00
Richard Cochran b1ce06206f port: Introduce an option to disable mutlicast service.
Some profiles forbid multicast altogther.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:07 -07:00
Richard Cochran b9b18268cd port: Hook into the unicast service logic.
Now that all the pieces are in place, hook the port logic into the
unicast service code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:07 -07:00
Richard Cochran 63598688b7 Introduce unicast service.
This patch adds new code that handles unicast service contracts,
sending messages according the negotiated schedule.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:07 -07:00
Richard Cochran dfa9e65785 fd: Introduce a unicast service timer.
This patch adds a new timer to be used by the server side unicast
negotiation logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran a076fd1ce9 Introduce a priority queue implementation.
This will be needed to keep track of multiple different deadlines
using a single timer.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran f71caedc57 port: Hook into the unicast client logic.
Now that all the pieces are in place, hook the port logic into the unicast
client code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran c2ab96fd40 port: Add a method for processing received signaling messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran e8e2be017a Support unicast peer to peer delay mechanism.
There are two aspects.  First, on the receive path, we reply to
unicast peer delay requests in kind.  That is, if the peer sends a
unicast delay request, then reply with unicast, too, since this is
obviously what the peer expects.

Second, if configured, we transmit peer delay requests to the
specified unicast peer address.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran faf0e0a025 Introduce unicast client logic.
This patch adds new code that runs the state machine and handles the
TLVs for requesting unicast service from a remote master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran ffdb3f7192 fd: Introduce a unicast request timer.
This patch adds a new timer to be used by the client side unicast
negotiation logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 1ccc55ef07 port: Add a method for constructing signaling messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 0fffa6c4b5 Introduce the unicast client finite state machine.
In order to implement client side unicast negotiation, state is needed
per port and master.  This patch adds the needed state machines.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran e22dc6b113 config: Introduce a unicast master table.
This patch adds configuration file support for a table of unicast
masters.  Each table lives in its own section and has a unique,
positive numerical ID.  Entries in the table are a pair of transport
type and protocol address.

Each port may specify a table id to be used for unicast negotiation.
Tables may not be shared between ports, but nothing prevents table
entries from appearing in more than table.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 1d450540c7 msg: Support unicast negotiation message formats.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran f94df4f625 port: Make the sync and announce transmit functions public.
These functions will be needed by the new unicast mode.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 05dce31d81 port: Allow transmission of unicast announce messages.
This will be needed by unicast mode.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:47 -07:00
Richard Cochran bc18131d27 util: Add a method to compare binary addresses.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:47 -07:00
Richard Cochran 40480f3b28 util: Make a useful helper function more public.
The function, str2addr(), will be needed by the upcoming unicast
client code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:47 -07:00
Richard Cochran ffbafa557b transport: Fix even more callers to pass a proper enumeration value.
All of the callers of transport_peer() use hard coded magic numbers.
This patch fixes them to use the corresponding enumerated values instead.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:25:34 -07:00
Rafaël Carré 5219b6417f udp*: multicast join work with specific addresses
Remove unused sockaddr size argument, and pass address using specific struct

Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré ee2a9d4ac9 follow_up_info_append: port argument is unused
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré d52ef498cf phc2sys: document switch/case fallthrough so that gcc can understand it
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré bdaff2ecd2 transport_txts(): transport argument is unused
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré 77995137bf config_alloc_longopts(): argument is unused
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré 3c7fa5dd42 clock_send_notification: msg_len is unused
message length is already included in the msg structure

Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Michael Walle 6bc77ccf4b Replace memcmp() with pid_eq() and cid_eq()
Consistenly use the pid_eq() and cid_eq() helper functions. Move the
functions into utils.h (making them inline functions) because they are
used in multiple source files.

Signed-off-by: Michael Walle <michael@walle.cc>
2018-06-21 07:18:24 -07:00
Cliff Spradlin via Linuxptp-devel 4c5d180ab3 phc2sys: don't over-control a destination clock
If ptp4l is running as a boundary clock, and multiple master ports
share a hardware clock that is different than the slave port's
hardware clock, then phc2sys in autocfg mode will synchronize that
clock multiple times per sync loop, once per-port.

Example output when this happens:
CLOCK_REALTIME phc offset        -9 s2 freq    -355 delay   3635
eth9 phc offset         9 s2 freq   +1762 delay   7488
eth8 phc offset        41 s2 freq   +1985 delay   7424
eth7 phc offset        15 s2 freq   +1952 delay   7440
eth6 phc offset        20 s2 freq   +1059 delay   7440
eth1 phc offset        22 s2 freq   +1783 delay   7424
eth12.400 phc offset        15 s2 freq -4207943 delay   7551
eth12.300 phc offset       388 s2 freq +2336645 delay   7536
eth12.200 phc offset       451 s2 freq +2516553 delay   7438
eth12.100 phc offset       268 s2 freq  +64274 delay   7405

This is easily reproducible by adding VLANs to a single network
interface and configuring ptp4l to use those VLAN interfaces as PTP
ports.

This patch prevents this problem by introducing a new deduplicated
destination clock list to phc2sys. Each time phc2sys reconfigures,
the destination clock list is re-populated. In the synchronization
loop, phc2sys will only use the clocks in this list.

Example output of reconfiguration with this patch:
reconfiguring after port state change
selecting eth9 for synchronization
selecting eth8 for synchronization
selecting eth7 for synchronization
selecting eth6 for synchronization
selecting eth1 for synchronization
selecting eth13.400 for synchronization
skipping eth13.300: eth13.400 has the same clock and is already selected
skipping eth13.200: eth13.400 has the same clock and is already selected
skipping eth13.100: eth13.400 has the same clock and is already selected
selecting eth12.400 for synchronization
skipping eth12.300: eth12.400 has the same clock and is already selected
skipping eth12.200: eth12.400 has the same clock and is already selected
skipping eth12.100: eth12.400 has the same clock and is already selected
skipping eth13.500: eth13.400 has the same clock and is already selected

This patch was tested with autocfg mode and also when specifying source
and destination manually via commandline.

Signed-off-by: Cliff Spradlin <cspradlin@google.com>
2018-06-18 11:01:56 -07:00
Cliff Spradlin via Linuxptp-devel dc0f6427bd port: don't clockcheck timestamps from other domains
ptp4l runs clockcheck on an incoming PTP message before checking its
domain number. If the time on another domain is different, then
clockcheck will trigger spurious synchronization faults.

This patch reorders the logic so that clockcheck only runs on messages
in the same time domain.

Reported-By: Filip Perich <perich@google.com>
Signed-off-by: Cliff Spradlin <cspradlin@google.com>
2018-06-13 21:15:19 -07:00
Richard Cochran ccfeb3b092 msg: Introduce a helper to test for unicast messages.
With increasing unicast support, the code needs to identify unicast
messages more often.  This patch replaces the open coded bit field
tests with a more readable in line helper function call.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 15:28:35 -07:00
Richard Cochran 28ddb51567 port: Don't take the interval from unicast sync messages.
According to the standard, unicast Sync messages are to be sent with
the interval field set to 127.  This patch adds a test to avoid
incorrectly adopting that value as a new interval.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 07:46:04 -07:00
Richard Cochran 494643d1fb port: Correct log message interval field of unicast Sync messages.
According to the standard, this field is special for unicast messages.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 07:46:03 -07:00
Richard Cochran a4981b2050 Move the configuration files to their own directory.
We will be getting more and more of these.  Let's put them into their
own area.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 07:46:03 -07:00
Christoph Seifert 1bf9d1e392 config: Fix value range for tc_spanning_tree option
This fix allows disabling tc_spanning_tree explicitly.

Signed-off-by: Christoph Seifert <christoph.seifert@posteo.me>
2018-05-17 10:41:59 -07:00
Richard Cochran a8b66ce7f2 Fix crash in hybrid E2E mode.
Richard Hill reported an occasional NULL pointer deference in
port_delay_request() when in hybrid mode.

	if (p->hybrid_e2e) {
		struct ptp_message *dst = TAILQ_FIRST(&p->best->messages);
		msg->address = dst->address;
		...
	}

The code assumes that the p->best->messages list can't be empty
because:

    The function, port_delay_request(), is called only when
    FD_DELAY_TIMER expires.  That timer is only set by the function,
    port_set_delay_tmo(), which is called:

    1. from process_delay_resp(), but only when state is UNCALIBRATED
       or SLAVE.

    2. from port_e2e_transition(), but only when state is UNCALIBRATED
       or SLAVE.

    Looking at handle_state_decision_event(), a port can only enter
    UNCALIBRATED or SLAVE when it has a valid foreign master record,
    ie p->best->messages is not null.

    A port also only clears p->best->messages when it leaves
    UNCALIBRATED or SLAVE, at which point the FD_DELAY_TIMER is also
    cleared.

*However* the p->best->messages list *can* be empty if the
FD_ANNOUNCE_TIMER and the FD_DELAY_TIMER expire at the same time.  In
this case, the poll() call indicates events on both file descriptors.
The announce timeout is handled like this:

	case FD_ANNOUNCE_TIMER:
        case FD_SYNC_RX_TIMER:
                if (p->best)
                        fc_clear(p->best);

So then the port_delay_request() call de-references the null
TAILQ_FIRST message pointer.

This patch fixes the issue by re-ordering the timer file descriptors
within the polling list.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Richard Hill <plonta@gmx.de>
2018-05-16 06:44:56 -07:00