Skip to content

Commit

Permalink
ppp: Add ppp_dev_name() exported function
Browse files Browse the repository at this point in the history
ppp_dev_name() gives PPP users visibility of a ppp channel's device
name. This can be used by L2TP drivers to dump the assigned PPP
interface name.

Signed-off-by: James Chapman <jchapman@katalix.com>
Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
James Chapman authored and David S. Miller committed Apr 3, 2010
1 parent fd558d1 commit 63f9607
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/net/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2162,6 +2162,24 @@ int ppp_unit_number(struct ppp_channel *chan)
return unit;
}

/*
* Return the PPP device interface name of a channel.
*/
char *ppp_dev_name(struct ppp_channel *chan)
{
struct channel *pch = chan->ppp;
char *name = NULL;

if (pch) {
read_lock_bh(&pch->upl);
if (pch->ppp && pch->ppp->dev)
name = pch->ppp->dev->name;
read_unlock_bh(&pch->upl);
}
return name;
}


/*
* Disconnect a channel from the generic layer.
* This must be called in process context.
Expand Down Expand Up @@ -2890,6 +2908,7 @@ EXPORT_SYMBOL(ppp_register_channel);
EXPORT_SYMBOL(ppp_unregister_channel);
EXPORT_SYMBOL(ppp_channel_index);
EXPORT_SYMBOL(ppp_unit_number);
EXPORT_SYMBOL(ppp_dev_name);
EXPORT_SYMBOL(ppp_input);
EXPORT_SYMBOL(ppp_input_error);
EXPORT_SYMBOL(ppp_output_wakeup);
Expand Down
3 changes: 3 additions & 0 deletions include/linux/ppp_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ extern int ppp_channel_index(struct ppp_channel *);
/* Get the unit number associated with a channel, or -1 if none */
extern int ppp_unit_number(struct ppp_channel *);

/* Get the device name associated with a channel, or NULL if none */
extern char *ppp_dev_name(struct ppp_channel *);

/*
* SMP locking notes:
* The channel code must ensure that when it calls ppp_unregister_channel,
Expand Down

0 comments on commit 63f9607

Please sign in to comment.