Loading...
Searching...
No Matches
plugin.c File Reference

Common path manager plugin functions. More...

`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <fcntl.h>`
`#include <dirent.h>`
`#include <dlfcn.h>`
`#include <errno.h>`
`#include <unistd.h>`
`#include <assert.h>`
`#include <ell/queue.h>`
`#include <ell/hashmap.h>`
`#include <ell/util.h>`
`#include <ell/log.h>`
`#include <linux/genetlink.h>`
`#include <mptcpd/private/plugin.h>`
`#include <mptcpd/plugin.h>`
Include dependency graph for plugin.c:

## Classes

struct | plugin_info
| Plugin information. More...
struct | plugin_address_info
| Convenience structure to bundle address information. More...
struct | plugin_interface_info
| Convenience structure to bundle interface information. More...

## Macros

#define | MPTCP_PM_NAME_LEN GENL_NAMSIZ

## Functions

bool | mptcpd_plugin_load (char const *dir, char const *default_name, struct l_queue const *plugins_to_load, struct mptcpd_pm *pm)
| Load mptcpd plugins.
void | mptcpd_plugin_unload (struct mptcpd_pm *pm)
| Unload mptcpd plugins.
bool | mptcpd_plugin_register_ops (char const *name, struct mptcpd_plugin_ops const *ops)
| Register path manager operations.
void | mptcpd_plugin_new_connection (char const *name, mptcpd_token_t token, struct sockaddr const *laddr, struct sockaddr const *raddr, bool server_side, struct mptcpd_pm *pm)
| Notify plugin of new MPTCP connection pending completion.
void | mptcpd_plugin_connection_established (mptcpd_token_t token, struct sockaddr const *laddr, struct sockaddr const *raddr, bool server_side, struct mptcpd_pm *pm)
| Notify plugin of MPTCP connection completion.
void | mptcpd_plugin_connection_closed (mptcpd_token_t token, struct mptcpd_pm *pm)
| Notify plugin of MPTCP connection closure.
void | mptcpd_plugin_new_address (mptcpd_token_t token, mptcpd_aid_t id, struct sockaddr const *addr, struct mptcpd_pm *pm)
| Notify plugin of new address advertised by a peer.
void | mptcpd_plugin_address_removed (mptcpd_token_t token, mptcpd_aid_t id, struct mptcpd_pm *pm)
| Notify plugin of address no longer advertised by a peer.
void | mptcpd_plugin_new_subflow (mptcpd_token_t token, struct sockaddr const *laddr, struct sockaddr const *raddr, bool backup, struct mptcpd_pm *pm)
| Notify plugin that a peer has joined the MPTCP connection.
void | mptcpd_plugin_subflow_closed (mptcpd_token_t token, struct sockaddr const *laddr, struct sockaddr const *raddr, bool backup, struct mptcpd_pm *pm)
| Notify plugin of MPTCP subflow closure.
void | mptcpd_plugin_subflow_priority (mptcpd_token_t token, struct sockaddr const *laddr, struct sockaddr const *raddr, bool backup, struct mptcpd_pm *pm)
| Notify plugin of MPTCP subflow priority change.
void | mptcpd_plugin_new_interface (struct mptcpd_interface const *i, void *pm)
| Notify plugin of new network interface.
void | mptcpd_plugin_update_interface (struct mptcpd_interface const *i, void *pm)
| Notify plugin of updated network interface.
void | mptcpd_plugin_delete_interface (struct mptcpd_interface const *i, void *pm)
| Notify plugin of removed network interface.
void | mptcpd_plugin_new_local_address (struct mptcpd_interface const *i, struct sockaddr const *sa, void *pm)
| Notify plugin of new network address.
void | mptcpd_plugin_delete_local_address (struct mptcpd_interface const *i, struct sockaddr const *sa, void *pm)
| Notify plugin of removed network address.

## Detailed Description

Common path manager plugin functions.

Copyright (c) 2018-2022, Intel Corporation

## Macro Definition Documentation

## MPTCP_PM_NAME_LEN

#define MPTCP_PM_NAME_LEN GENL_NAMSIZ

Todo:
  Remove this preprocessor symbol definition once support for path management strategy names are supported in the new generic netlink API.

Note
  `GENL_NAMSIZ` is used as the size since the path manager name attribute in the deprecated MPTCP generic netlink API contained a fixed length string of that size.

## Function Documentation

## mptcpd_plugin_address_removed()

void mptcpd_plugin_address_removed | ( | mptcpd_token_t | token,
|  | mptcpd_aid_t | id,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of address no longer advertised by a peer.

Parameters

  [in] | token | MPTCP connection token.
  [in] | id | Remote address identifier.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_connection_closed()

void mptcpd_plugin_connection_closed | ( | mptcpd_token_t | token,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of MPTCP connection closure.

Parameters

  [in] | token | MPTCP connection token.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_connection_established()

void mptcpd_plugin_connection_established | ( | mptcpd_token_t | token,
|  | struct sockaddr const * | laddr,
|  | struct sockaddr const * | raddr,
|  | bool | server_side,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of MPTCP connection completion.

Parameters

  [in] | token | MPTCP connection token.
  [in] | laddr | Local address information.
  [in] | raddr | Remote address information.
  [in] | server_side | Server side connection flag.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_delete_interface()

void mptcpd_plugin_delete_interface | ( | struct mptcpd_interface const * | i,
|  | void * | pm
| ) |  |

Notify plugin of removed network interface.

Parameters

  [in] | i | Network interface information.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_delete_local_address()

void mptcpd_plugin_delete_local_address | ( | struct mptcpd_interface const * | i,
|  | struct sockaddr const * | sa,
|  | void * | pm
| ) |  |

Notify plugin of removed network address.

Parameters

  [in] | i | Network interface information.
  [in] | sa | Network address information.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_load()

bool mptcpd_plugin_load | ( | char const * | dir,
|  | char const * | default_name,
|  | struct l_queue const * | plugins_to_load,
|  | struct mptcpd_pm * | pm
| ) |  |

Load mptcpd plugins.

Parameters

  [in] | dir | Directory from which plugins will be loaded.
  [in] | default_name | Name of plugin to be considered the default.
  [in] | plugins_to_load | List of plugins to be loaded.
  [in] | pm | Opaque pointer to mptcpd path manager object.

Returns
  `true` on successful load, `false` otherwise.

Create map of connection token to path manager plugin.

Note
  We use the default ELL direct hash function that converts from a pointer to an `unsigned` `int`.

Todo:
  Determine if this is a performance bottleneck on 64 bit platforms since it is possible that connection IDs may end up in the same hash bucket due to the truncation from 64 bits to 32 bits in ELL's direct hash function, assuming `unsigned` `int` is a 32 bit type.

## mptcpd_plugin_new_address()

void mptcpd_plugin_new_address | ( | mptcpd_token_t | token,
|  | mptcpd_aid_t | id,
|  | struct sockaddr const * | addr,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of new address advertised by a peer.

Parameters

  [in] | token | MPTCP connection token.
  [in] | id | Remote address identifier.
  [in] | addr | Remote address information.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_new_connection()

void mptcpd_plugin_new_connection | ( | char const * | name,
|  | mptcpd_token_t | token,
|  | struct sockaddr const * | laddr,
|  | struct sockaddr const * | raddr,
|  | bool | server_side,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of new MPTCP connection pending completion.

Parameters

  [in] | name | Plugin name.
  [in] | token | MPTCP connection token.
  [in] | laddr | Local address information.
  [in] | raddr | Remote address information.
  [in] | server_side | Server side connection flag.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_new_interface()

void mptcpd_plugin_new_interface | ( | struct mptcpd_interface const * | i,
|  | void * | pm
| ) |  |

Notify plugin of new network interface.

Parameters

  [in] | i | Network interface information.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_new_local_address()

void mptcpd_plugin_new_local_address | ( | struct mptcpd_interface const * | i,
|  | struct sockaddr const * | sa,
|  | void * | pm
| ) |  |

Notify plugin of new network address.

Parameters

  [in] | i | Network interface information.
  [in] | sa | Network address information.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_new_subflow()

void mptcpd_plugin_new_subflow | ( | mptcpd_token_t | token,
|  | struct sockaddr const * | laddr,
|  | struct sockaddr const * | raddr,
|  | bool | backup,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin that a peer has joined the MPTCP connection.

Parameters

  [in] | token | MPTCP connection token.
  [in] | laddr | Local address information.
  [in] | raddr | Remote address information.
  [in] | backup | Backup priority flag.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_register_ops()

bool mptcpd_plugin_register_ops | ( | char const * | name,
|  | struct mptcpd_plugin_ops const * | ops
| ) |  |

Register path manager operations.

Path manager plugins should call this function in their `init` function to register their MPTCP path manager event handling functions.

Parameters

  [in] | name | Plugin name.
  [in] | ops | Set of MPTCP path manager event handling functions provided by the path manager plugin.

Return values

  true | Registration succeeded.
  false | Registration failed. Failure should only occur if plugins were not loaded prior to calling this function. Plugin developers should generally not have to worry about that since the load is guaranteed to have occurred prior to their `init` function being called.

Todo:
  Should we return `false` if all of the callbacks in ops are `NULL`?

## mptcpd_plugin_subflow_closed()

void mptcpd_plugin_subflow_closed | ( | mptcpd_token_t | token,
|  | struct sockaddr const * | laddr,
|  | struct sockaddr const * | raddr,
|  | bool | backup,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of MPTCP subflow closure.

Parameters

  [in] | token | MPTCP connection token.
  [in] | laddr | Local address information.
  [in] | raddr | Remote address information.
  [in] | backup | Backup priority flag.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_subflow_priority()

void mptcpd_plugin_subflow_priority | ( | mptcpd_token_t | token,
|  | struct sockaddr const * | laddr,
|  | struct sockaddr const * | raddr,
|  | bool | backup,
|  | struct mptcpd_pm * | pm
| ) |  |

Notify plugin of MPTCP subflow priority change.

Parameters

  [in] | token | MPTCP connection token.
  [in] | laddr | Local address information.
  [in] | raddr | Remote address information.
  [in] | backup | Backup priority flag.
  [in] | pm | Opaque pointer to mptcpd path manager object.

## mptcpd_plugin_unload()

void mptcpd_plugin_unload | ( | struct mptcpd_pm * | pm | ) |

Unload mptcpd plugins.

Parameters

  [in] | pm | Opaque pointer to mptcpd path manager object.

Note
  This isn't thread-safe. We'll need a lock if we ever support destroying multiple path managers from different threads. However, right now there doesn't appear to be a need to support that.

## mptcpd_plugin_update_interface()

void mptcpd_plugin_update_interface | ( | struct mptcpd_interface const * | i,
|  | void * | pm
| ) |  |

Notify plugin of updated network interface.

Parameters

  [in] | i | Network interface information.
  [in] | pm | Opaque pointer to mptcpd path manager object.